@@ -274,6 +274,90 @@ async def test_state_standby(aresponses):
274274 assert response .program is None
275275
276276
277+ @pytest .mark .asyncio
278+ async def test_status (aresponses ):
279+ """Test active state is handled correctly."""
280+ aresponses .add (
281+ MATCH_HOST ,
282+ "/info/mode" ,
283+ "GET" ,
284+ aresponses .Response (
285+ status = 200 ,
286+ headers = {"Content-Type" : "application/json" },
287+ text = load_fixture ("info-mode.json" ),
288+ ),
289+ )
290+
291+ async with ClientSession () as session :
292+ dtv = DIRECTV (HOST , session = session )
293+ response = await dtv .status ()
294+
295+ assert response == "active"
296+
297+
298+ @pytest .mark .asyncio
299+ async def test_status_access_restricted (aresponses ):
300+ """Test unauthorized state is handled correctly."""
301+ aresponses .add (
302+ MATCH_HOST ,
303+ "/info/mode" ,
304+ "GET" ,
305+ aresponses .Response (
306+ status = 403 ,
307+ headers = {"Content-Type" : "application/json" },
308+ text = load_fixture ("info-mode-restricted.json" ),
309+ ),
310+ )
311+
312+ async with ClientSession () as session :
313+ dtv = DIRECTV (HOST , session = session )
314+ response = await dtv .status ()
315+
316+ assert response == "unauthorized"
317+
318+
319+ @pytest .mark .asyncio
320+ async def test_status_standby (aresponses ):
321+ """Test standby status is handled correctly."""
322+ aresponses .add (
323+ MATCH_HOST ,
324+ "/info/mode" ,
325+ "GET" ,
326+ aresponses .Response (
327+ status = 200 ,
328+ headers = {"Content-Type" : "application/json" },
329+ text = load_fixture ("info-mode-standby.json" ),
330+ ),
331+ )
332+
333+ async with ClientSession () as session :
334+ dtv = DIRECTV (HOST , session = session )
335+ response = await dtv .status ()
336+
337+ assert response == "standby"
338+
339+
340+ @pytest .mark .asyncio
341+ async def test_status_unavailable (aresponses ):
342+ """Test unavailable status is handled correctly."""
343+ aresponses .add (
344+ MATCH_HOST ,
345+ "/info/mode" ,
346+ "GET" ,
347+ aresponses .Response (
348+ status = 500 ,
349+ headers = {"Content-Type" : "application/json" },
350+ text = load_fixture ("info-mode-error.json" ),
351+ ),
352+ )
353+
354+ async with ClientSession () as session :
355+ dtv = DIRECTV (HOST , session = session )
356+ response = await dtv .status ()
357+
358+ assert response == "unavailable"
359+
360+
277361@pytest .mark .asyncio
278362async def test_tune (aresponses ):
279363 """Test tune is handled correctly."""
0 commit comments