@@ -165,6 +165,78 @@ async def test_missing_last_tile_state(aresponses, create_session_response):
165165 assert not tile .longitude
166166
167167
168+ @pytest .mark .asyncio
169+ async def test_tile_as_dict (aresponses , create_session_response ):
170+ """Test dumping a Tile as a dictionary."""
171+ aresponses .add (
172+ "production.tile-api.com" ,
173+ f"/api/v1/clients/{ TILE_CLIENT_UUID } " ,
174+ "put" ,
175+ aresponses .Response (
176+ text = load_fixture ("create_client_response.json" ),
177+ status = 200 ,
178+ headers = {"Content-Type" : "application/json" },
179+ ),
180+ )
181+ aresponses .add (
182+ "production.tile-api.com" ,
183+ f"/api/v1/clients/{ TILE_CLIENT_UUID } /sessions" ,
184+ "post" ,
185+ aresponses .Response (
186+ text = json .dumps (create_session_response ),
187+ status = 200 ,
188+ headers = {"Content-Type" : "application/json" },
189+ ),
190+ )
191+ aresponses .add (
192+ "production.tile-api.com" ,
193+ "/api/v1/tiles/tile_states" ,
194+ "get" ,
195+ aresponses .Response (
196+ text = load_fixture ("tile_states_response.json" ),
197+ status = 200 ,
198+ headers = {"Content-Type" : "application/json" },
199+ ),
200+ )
201+ aresponses .add (
202+ "production.tile-api.com" ,
203+ f"/api/v1/tiles/{ TILE_TILE_UUID } " ,
204+ "get" ,
205+ aresponses .Response (
206+ text = load_fixture ("tile_details_response.json" ),
207+ status = 200 ,
208+ headers = {"Content-Type" : "application/json" },
209+ ),
210+ )
211+
212+ async with aiohttp .ClientSession () as session :
213+ api = await async_login (
214+ TILE_EMAIL , TILE_PASSWORD , session , client_uuid = TILE_CLIENT_UUID
215+ )
216+ tiles = await api .async_get_tiles ()
217+ assert len (tiles ) == 1
218+ tile = tiles [TILE_TILE_UUID ]
219+ assert tile .as_dict () == {
220+ "accuracy" : 13.496111 ,
221+ "altitude" : 0.4076319168123 ,
222+ "archetype" : "WALLET" ,
223+ "dead" : False ,
224+ "firmware_version" : "01.12.14.0" ,
225+ "hardware_version" : "02.09" ,
226+ "kind" : "TILE" ,
227+ "last_timestamp" : datetime (2020 , 8 , 12 , 17 , 55 , 26 ),
228+ "latitude" : 51.528308 ,
229+ "longitude" : - 0.3817765 ,
230+ "lost" : False ,
231+ "lost_timestamp" : datetime (1969 , 12 , 31 , 23 , 59 , 59 , 999000 ),
232+ "name" : "Wallet" ,
233+ "ring_state" : "STOPPED" ,
234+ "uuid" : "19264d2dffdbca32" ,
235+ "visible" : True ,
236+ "voip_state" : "OFFLINE" ,
237+ }
238+
239+
168240@pytest .mark .asyncio
169241async def test_tile_update (
170242 aresponses , create_session_response , tile_details_update_response
0 commit comments