diff options
-rw-r--r-- | pyagl/services/base.py | 4 | ||||
-rw-r--r-- | pyagl/tests/test_gps.py | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/pyagl/services/base.py b/pyagl/services/base.py index 42468a8..766a51b 100644 --- a/pyagl/services/base.py +++ b/pyagl/services/base.py @@ -238,7 +238,9 @@ class AGLBaseService: self.logger.error("Unhandled seal: " + str(e)) async def afbresponse(self): - return AFBResponse(await self.response()) + resp = await self.response() + if resp is not None: + return AFBResponse(resp) async def request(self, verb: str, values: Union[str, dict] = "", msgid: int = None, api=None): msgid = next(newrand()) if msgid is None else msgid diff --git a/pyagl/tests/test_gps.py b/pyagl/tests/test_gps.py index 3bfeb48..9bcd073 100644 --- a/pyagl/tests/test_gps.py +++ b/pyagl/tests/test_gps.py @@ -48,13 +48,13 @@ async def test_subscribe_verb(event_loop, service: GPS): assert resp.msgid == msgid assert resp.status == 'success' - +@pytest.mark.dependency async def test_enable_recording(event_loop, service: GPS): msgid = await service.record() resp = await service.afbresponse() assert resp.status == 'success', resp.info - +@pytest.mark.dependency(depends=['test_enable_recording']) async def test_disable_recording(event_loop, service: GPS): msgid = await service.record('off') resp = await service.afbresponse() @@ -76,11 +76,13 @@ async def test_location_events(event_loop, service: GPS): resp = await service.afbresponse() assert resp.msgid == msgid assert resp.status == 'success' # successful subscription + task = asyncio.create_task(service.afbresponse()) try: - resp = await asyncio.wait_for(service.afbresponse(), 10) + resp = await asyncio.wait_for(task, 10) assert resp.type == AFBT.EVENT, f'Expected EVENT response, got {resp.type.name} instead' # TODO one more assert for the actual received event, haven't received a location event yet except TimeoutError: + task.cancel() pytest.xfail("Did not receive location event") |