@@ -64,6 +64,29 @@ async def test_states(
6464 await opensky .close ()
6565
6666
67+ async def test_unavailable_states (
68+ aresponses : ResponsesMockServer ,
69+ ) -> None :
70+ """Test retrieving no states."""
71+ aresponses .add (
72+ OPENSKY_URL ,
73+ "/api/states/all" ,
74+ "GET" ,
75+ aresponses .Response (
76+ status = 200 ,
77+ headers = {"Content-Type" : "application/json" },
78+ text = load_fixture ("unavailable_states.json" ),
79+ ),
80+ )
81+ async with aiohttp .ClientSession () as session :
82+ opensky = OpenSky (session = session )
83+ response : StatesResponse = await opensky .get_states ()
84+ assert response .states is not None
85+ assert len (response .states ) == 0
86+ assert response .time == 1683488744
87+ await opensky .close ()
88+
89+
6790async def test_own_states (
6891 aresponses : ResponsesMockServer ,
6992) -> None :
@@ -87,6 +110,30 @@ async def test_own_states(
87110 await opensky .close ()
88111
89112
113+ async def test_unavailable_own_states (
114+ aresponses : ResponsesMockServer ,
115+ ) -> None :
116+ """Test retrieving no own states."""
117+ aresponses .add (
118+ OPENSKY_URL ,
119+ "/api/states/own" ,
120+ "GET" ,
121+ aresponses .Response (
122+ status = 200 ,
123+ headers = {"Content-Type" : "application/json" },
124+ text = load_fixture ("unavailable_states.json" ),
125+ ),
126+ )
127+ async with aiohttp .ClientSession () as session :
128+ opensky = OpenSky (session = session )
129+ opensky .authenticate (BasicAuth (login = "test" , password = "test" ))
130+ response : StatesResponse = await opensky .get_own_states ()
131+ assert response .states is not None
132+ assert len (response .states ) == 0
133+ assert response .time == 1683488744
134+ await opensky .close ()
135+
136+
90137async def test_states_with_bounding_box (
91138 aresponses : ResponsesMockServer ,
92139) -> None :
0 commit comments