diff options
-rw-r--r-- | pyagl/services/can.py | 37 | ||||
-rw-r--r-- | pyagl/tests/test_audiomixer.py | 9 | ||||
-rw-r--r-- | pyagl/tests/test_bluetooth.py | 21 | ||||
-rw-r--r-- | pyagl/tests/test_bluetooth_map.py | 10 | ||||
-rw-r--r-- | pyagl/tests/test_bluetooth_pbap.py | 29 | ||||
-rw-r--r-- | pyagl/tests/test_can.py | 52 | ||||
-rw-r--r-- | pyagl/tests/test_geoclue.py | 5 | ||||
-rw-r--r-- | pyagl/tests/test_gps.py | 14 | ||||
-rw-r--r-- | pyagl/tests/test_mediascanner.py | 5 | ||||
-rw-r--r-- | pyagl/tests/test_network.py | 32 | ||||
-rw-r--r-- | pyagl/tests/test_nfc.py | 4 | ||||
-rw-r--r-- | pyagl/tests/test_weather.py | 14 |
12 files changed, 116 insertions, 116 deletions
diff --git a/pyagl/services/can.py b/pyagl/services/can.py index f345c92..7e8df9a 100644 --- a/pyagl/services/can.py +++ b/pyagl/services/can.py @@ -1,20 +1,53 @@ from pyagl.services.base import AGLBaseService, AFBResponse import asyncio +import json import os class CANService(AGLBaseService): service = 'service-can-low' parser = AGLBaseService.getparser() + parser.add_argument('--auth', help='Send an authentication request', action='store_true') + parser.add_argument('--write', metavar='JSON', help='Write values to CAN') + parser.add_argument('--list', help='List CAN signals', action='store_true') - def __init__(self, ip, port=None, service='service-can-low'): - super().__init__(api='signal-composer', ip=ip, port=port, service=service) + def __init__(self, ip, port=None, service='service-can-low-level'): + super().__init__(api='low-can', ip=ip, port=port, service=service) # more init stuff specific to the new service + async def auth(self): + return await self.request('auth') + + async def write(self, values: dict, msgid=None): + return await self.request('write', values, msgid=msgid) + + async def get(self, event): + return await self.request('get', {'event': event}) + + async def list(self): + return await self.request('list') + async def main(loop): args = CANService.parser.parse_args() svc = await CANService(args.ipaddr) + sessionid = 0 + if args.auth: + sessionid = await svc.auth() + data = await svc.afbresponse() + print(data) + + if args.list: + msgid = await svc.list() + data = await svc.afbresponse() + print(data) + + if args.write: + values = json.loads(args.write) + msgid = await svc.write(values, msgid=sessionid) + data = await svc.afbresponse() + print(data) + if __name__ == '__main__': loop = asyncio.get_event_loop() diff --git a/pyagl/tests/test_audiomixer.py b/pyagl/tests/test_audiomixer.py index 640c6cb..5479521 100644 --- a/pyagl/tests/test_audiomixer.py +++ b/pyagl/tests/test_audiomixer.py @@ -6,7 +6,7 @@ from pyagl.services.base import AFBResponse, AFBT from pyagl.services.audiomixer import AudioMixerService as AMS import logging -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.audiomixer] @pytest.fixture(scope='module') @@ -26,7 +26,6 @@ async def service(): @pytest.mark.regular -@pytest.mark.audiomixer async def test_list_controls(event_loop, service: AMS): msgid = await service.list_controls() resp = await service.afbresponse() @@ -36,7 +35,6 @@ async def test_list_controls(event_loop, service: AMS): @pytest.mark.regular -@pytest.mark.audiomixer async def test_volume_verb(event_loop, service: AMS): msgid = await service.volume() resp = await service.afbresponse() @@ -46,7 +44,6 @@ async def test_volume_verb(event_loop, service: AMS): @pytest.mark.regular -@pytest.mark.audiomixer async def test_set_volume0(event_loop, service: AMS): msgid = await service.volume(value=0) resp = await service.afbresponse() @@ -56,7 +53,6 @@ async def test_set_volume0(event_loop, service: AMS): @pytest.mark.regular -@pytest.mark.audiomixer async def test_set_maxvolume(event_loop, service: AMS): msgid = await service.volume(value=1) resp = await service.afbresponse() @@ -66,7 +62,6 @@ async def test_set_maxvolume(event_loop, service: AMS): @pytest.mark.regular -@pytest.mark.audiomixer async def test_get_mute(event_loop, service: AMS): msgid = await service.mute() resp = await service.afbresponse() @@ -76,7 +71,6 @@ async def test_get_mute(event_loop, service: AMS): @pytest.mark.regular -@pytest.mark.audiomixer async def test_set_mute(event_loop, service: AMS): msgid = await service.mute(value=1) resp = await service.afbresponse() @@ -86,7 +80,6 @@ async def test_set_mute(event_loop, service: AMS): @pytest.mark.regular -@pytest.mark.audiomixer async def test_set_unmute(event_loop, service: AMS): msgid = await service.mute(value=0) resp = await service.afbresponse() diff --git a/pyagl/tests/test_bluetooth.py b/pyagl/tests/test_bluetooth.py index 2ae4287..78f1d21 100644 --- a/pyagl/tests/test_bluetooth.py +++ b/pyagl/tests/test_bluetooth.py @@ -8,7 +8,7 @@ import logging logger = logging.getLogger(f'pytest-{BTS.service}') logger.setLevel(logging.DEBUG) -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.bluetooth] @pytest.fixture(scope='module') @@ -28,7 +28,6 @@ async def service(): @pytest.mark.xfail -@pytest.mark.bluetooth @pytest.fixture(scope='module') def btaddr(): bthtestaddr = os.environ.get('AGL_BT_TEST_ADDR', None) @@ -40,7 +39,6 @@ def btaddr(): @pytest.mark.regular -@pytest.mark.bluetooth @pytest.mark.dependency async def test_default_adapter(event_loop, service: BTS): msgid = await service.default_adapter('hci0') @@ -51,7 +49,6 @@ async def test_default_adapter(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_subscribe_device_changes(event_loop, service: BTS): msgid = await service.subscribe('device_changes') resp = await service.afbresponse() @@ -59,7 +56,6 @@ async def test_subscribe_device_changes(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_unsubscribe_device_changes(event_loop, service: BTS): msgid = await service.unsubscribe('device_changes') resp = await service.afbresponse() @@ -67,7 +63,6 @@ async def test_unsubscribe_device_changes(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_subscribe_adapter_changes(event_loop, service: BTS): msgid = await service.subscribe('adapter_changes') resp = await service.afbresponse() @@ -75,7 +70,6 @@ async def test_subscribe_adapter_changes(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_unsubscribe_adapter_changes(event_loop, service: BTS): msgid = await service.unsubscribe('adapter_changes') resp = await service.afbresponse() @@ -83,7 +77,6 @@ async def test_unsubscribe_adapter_changes(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_subscribe_media(event_loop, service: BTS): msgid = await service.subscribe('media') resp = await service.afbresponse() @@ -91,7 +84,6 @@ async def test_subscribe_media(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_unsubscribe_media(event_loop, service: BTS): msgid = await service.unsubscribe('media') resp = await service.afbresponse() @@ -99,7 +91,6 @@ async def test_unsubscribe_media(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_subscribe_agent(event_loop, service: BTS): msgid = await service.subscribe('agent') resp = await service.afbresponse() @@ -107,14 +98,12 @@ async def test_subscribe_agent(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth async def test_unsubscribe_agent(event_loop, service: BTS): msgid = await service.unsubscribe('agent') resp = await service.afbresponse() assert resp.status == 'success', resp.info @pytest.mark.regular -@pytest.mark.bluetooth @pytest.mark.dependency(depends=['test_default_adapter']) async def test_managed_objects(event_loop, service: BTS): msgid = await service.managed_objects() @@ -122,7 +111,6 @@ async def test_managed_objects(event_loop, service: BTS): assert resp.status == 'success', resp.info @pytest.mark.hwrequired -@pytest.mark.bluetooth async def test_has_single_adapter(event_loop, service: BTS): msgid = await service.managed_objects() resp = await service.afbresponse() @@ -131,7 +119,6 @@ async def test_has_single_adapter(event_loop, service: BTS): @pytest.mark.regular -@pytest.mark.bluetooth @pytest.mark.dependency(depends=['test_default_adapter']) async def test_adapter_state(event_loop, service: BTS): msgid = await service.adapter_state('hci0') @@ -140,7 +127,6 @@ async def test_adapter_state(event_loop, service: BTS): @pytest.mark.hwrequired -@pytest.mark.bluetooth async def test_pairing_verb(event_loop, service: BTS, btaddr): msgid = await service.pair(btaddr) resp = await service.afbresponse() @@ -149,7 +135,6 @@ async def test_pairing_verb(event_loop, service: BTS, btaddr): @pytest.mark.hwrequired -@pytest.mark.bluetooth @pytest.mark.dependency async def test_connect_verb(event_loop, service: BTS, btaddr): msgid = await service.connect(btaddr) @@ -159,7 +144,6 @@ async def test_connect_verb(event_loop, service: BTS, btaddr): @pytest.mark.hwrequired -@pytest.mark.bluetooth @pytest.mark.xfail(reason='This is expected to fail because there has to be an ongoing pairing attempt') async def test_confirm_pairing_verb(event_loop, service: BTS, btaddr): msgid = await service.confirm_pairing(pincode='123456') @@ -169,7 +153,6 @@ async def test_confirm_pairing_verb(event_loop, service: BTS, btaddr): @pytest.mark.hwrequired -@pytest.mark.bluetooth @pytest.mark.dependency(depends=['test_connect_verb']) async def test_avrcp_controls(event_loop, service: BTS): avrcp_actions = ['Play', 'Pause', 'Stop', 'Next', 'Previous'] @@ -181,7 +164,6 @@ async def test_avrcp_controls(event_loop, service: BTS): @pytest.mark.hwrequired -@pytest.mark.bluetooth async def test_disconnect_verb(event_loop, service: BTS, btaddr): msgid = await service.disconnect(btaddr) resp = await service.afbresponse() @@ -190,7 +172,6 @@ async def test_disconnect_verb(event_loop, service: BTS, btaddr): @pytest.mark.hwrequired -@pytest.mark.bluetooth async def test_remove_pairing_verb(event_loop, service: BTS, btaddr): msgid = await service.remove_device(btaddr) resp = await service.afbresponse() diff --git a/pyagl/tests/test_bluetooth_map.py b/pyagl/tests/test_bluetooth_map.py index 871dc76..f750347 100644 --- a/pyagl/tests/test_bluetooth_map.py +++ b/pyagl/tests/test_bluetooth_map.py @@ -6,7 +6,7 @@ from pyagl.services.base import AFBResponse, AFBT from pyagl.services.bluetooth_map import BTMAPService as BMP import logging -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.btmap] @pytest.fixture(scope='module') @@ -41,7 +41,6 @@ def composetext(): @pytest.mark.hwrequired -@pytest.mark.btmap @pytest.mark.xfail(reason='Expected to fail if no messages are found') @pytest.fixture(scope='module') async def messages(service: BMP): @@ -53,7 +52,6 @@ async def messages(service: BMP): @pytest.mark.hwrequired -@pytest.mark.btmap @pytest.mark.dependency async def test_list_messages(event_loop, service: BMP): msgid = await service.list_messages() @@ -62,7 +60,6 @@ async def test_list_messages(event_loop, service: BMP): @pytest.mark.hwrequired -@pytest.mark.btmap @pytest.mark.dependency(depends=['test_list_messages']) @pytest.mark.xfail(reason='Expected to fail if there are no messages, need message id to test the verb') async def test_message_verb(event_loop, service, messages): @@ -72,8 +69,8 @@ async def test_message_verb(event_loop, service, messages): resp = await service.afbresponse() assert resp.status == 'success' + @pytest.mark.regular -@pytest.mark.btmap @pytest.mark.dependency async def test_subscribe_notifications(event_loop, service: BMP): msgid = await service.subscribe('notification') @@ -83,7 +80,6 @@ async def test_subscribe_notifications(event_loop, service: BMP): @pytest.mark.hwrequired -@pytest.mark.btmap @pytest.mark.dependency async def test_compose_message(event_loop, service: BMP, recipient, composetext): msgid = await service.compose(recipient, composetext) @@ -92,7 +88,6 @@ async def test_compose_message(event_loop, service: BMP, recipient, composetext) @pytest.mark.hwrequired -@pytest.mark.btmap @pytest.mark.dependency(depends=['test_compose_message', 'test_subscribe_notifications']) async def test_message_to_self(event_loop, service: BMP, recipient, composetext): resp = await service.afbresponse() @@ -104,7 +99,6 @@ async def test_message_to_self(event_loop, service: BMP, recipient, composetext) @pytest.mark.hwrequired -@pytest.mark.btmap @pytest.mark.dependency(depends=['test_subscribe_notifications']) async def test_unsubscribe_notifications(event_loop, service: BMP): msgid = await service.unsubscribe('notification') diff --git a/pyagl/tests/test_bluetooth_pbap.py b/pyagl/tests/test_bluetooth_pbap.py index d13ede2..c76a15f 100644 --- a/pyagl/tests/test_bluetooth_pbap.py +++ b/pyagl/tests/test_bluetooth_pbap.py @@ -6,7 +6,7 @@ import logging from pyagl.services.base import AFBResponse, AFBT from pyagl.services.bluetooth_pbap import BTPBAPService as PBAP -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.btpbap] @pytest.fixture(scope='module') @@ -43,7 +43,6 @@ def searchvcf(): @pytest.mark.regular -@pytest.mark.btpbap @pytest.mark.dependency async def test_status(event_loop, service: PBAP): msgid = await service.status() @@ -55,14 +54,14 @@ async def test_status(event_loop, service: PBAP): pytest.xfail('BT PBAP is not currently connected to the phone') assert resp.data['connected'] is True -@pytest.mark.btpbap + @pytest.mark.hwrequired async def test_search(event_loop, service: PBAP, phonenumber): msgid = await service.search(phonenumber) resp = await service.afbresponse() assert resp.status == 'success' -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_status']) async def test_import_contacts(event_loop, service: PBAP): @@ -75,7 +74,7 @@ async def test_import_contacts(event_loop, service: PBAP): assert len(vcards) > 0 print(f' import verb from OBEX returned {len(vcards)} .vcf objects ') -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_import_contacts']) async def test_contacts(event_loop, service: PBAP): @@ -88,7 +87,7 @@ async def test_contacts(event_loop, service: PBAP): assert len(vcards) > 0 print(f' contacts verb returned {len(vcards)} cached .vcf objects ') -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_history_incoming_calls(event_loop, service: PBAP): @@ -99,7 +98,7 @@ async def test_history_incoming_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_history_outgoing_calls(event_loop, service: PBAP): @@ -110,7 +109,7 @@ async def test_history_outgoing_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_history_missed_calls(event_loop, service: PBAP): @@ -121,7 +120,7 @@ async def test_history_missed_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_history_combined_calls(event_loop, service: PBAP): @@ -132,7 +131,7 @@ async def test_history_combined_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_entry_phonebook_verb(event_loop, service: PBAP, searchvcf): @@ -140,7 +139,7 @@ async def test_entry_phonebook_verb(event_loop, service: PBAP, searchvcf): resp = await service.afbresponse() assert resp.status == 'success', resp.info -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_entry_phonebook_verb']) async def test_entry_phonebook(event_loop, service: PBAP, searchvcf): @@ -150,7 +149,7 @@ async def test_entry_phonebook(event_loop, service: PBAP, searchvcf): if resp.data['vcards'] is None: pytest.xfail('The response did not contain "vcards" entries') -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_incoming_calls(event_loop, service: PBAP): @@ -161,7 +160,7 @@ async def test_incoming_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_outgoing_calls(event_loop, service: PBAP): @@ -172,7 +171,7 @@ async def test_outgoing_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_missed_calls(event_loop, service: PBAP): @@ -183,7 +182,7 @@ async def test_missed_calls(event_loop, service: PBAP): vcards = resp.data['vcards'] assert len(vcards) > 0 -@pytest.mark.btpbap + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_contacts']) async def test_combined_calls(event_loop, service: PBAP): diff --git a/pyagl/tests/test_can.py b/pyagl/tests/test_can.py new file mode 100644 index 0000000..1283939 --- /dev/null +++ b/pyagl/tests/test_can.py @@ -0,0 +1,52 @@ +import asyncio +import os +import pytest +import logging +from pyagl.services.base import AFBResponse, AFBT + +from pyagl.services.can import CANService as cs +pytestmark = [pytest.mark.asyncio, pytest.mark.can] + + +@pytest.fixture(scope='module') +def event_loop(): + loop = asyncio.get_event_loop() + yield loop + + +@pytest.fixture(scope='module') +async def service(): + address = os.environ.get('AGL_TGT_IP', 'localhost') + port = os.environ.get('AGL_TGT_PORT', None) + svc = await cs(ip=address, port=port) + yield svc + await svc.websocket.close() + + +@pytest.mark.regular +async def test_list(event_loop, service: cs): + msgid = await service.list() + resp = await service.afbresponse() + assert resp.status == 'success' + + +@pytest.mark.regular +async def test_get(event_loop, service: cs): + msgid = await service.get("engine.speed") + resp = await service.afbresponse() + assert resp.status == 'success' + + +@pytest.mark.regular +async def test_auth(event_loop, service: cs): + msgid = await service.auth() + resp = await service.afbresponse() + assert resp.status == 'success' + + +@pytest.mark.regular +async def test_write(event_loop, service: cs): + msgid = await service.write({"signal_name": "hvac.temperature.left", "signal_value": 21}) + resp = await service.afbresponse() + assert resp.status == 'success' + diff --git a/pyagl/tests/test_geoclue.py b/pyagl/tests/test_geoclue.py index d5a8853..7a1ec23 100644 --- a/pyagl/tests/test_geoclue.py +++ b/pyagl/tests/test_geoclue.py @@ -5,7 +5,7 @@ import logging from pyagl.services.base import AFBResponse, AFBT from pyagl.services.geoclue import GeoClueService as gcs -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.geoclue] @pytest.fixture(scope='module') @@ -24,7 +24,6 @@ async def service(): @pytest.mark.regular -@pytest.mark.geoclue async def test_location(event_loop, service: gcs): msgid = await service.location() resp = await service.afbresponse() @@ -34,7 +33,6 @@ async def test_location(event_loop, service: gcs): @pytest.mark.regular -@pytest.mark.geoclue async def test_subscribe(event_loop, service: gcs): msgid = await service.subscribe() resp = await service.afbresponse() @@ -45,7 +43,6 @@ async def test_subscribe(event_loop, service: gcs): @pytest.mark.regular -@pytest.mark.geoclue async def test_unsubscribe(event_loop, service: gcs): msgid = await service.unsubscribe() resp = await service.afbresponse() diff --git a/pyagl/tests/test_gps.py b/pyagl/tests/test_gps.py index 2753b89..d9f0562 100644 --- a/pyagl/tests/test_gps.py +++ b/pyagl/tests/test_gps.py @@ -6,7 +6,7 @@ from pyagl.services.base import AFBResponse, AFBT from pyagl.services.gps import GPSService as GPS from asyncio.exceptions import TimeoutError -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.gps] @pytest.fixture(scope='module') @@ -28,14 +28,14 @@ async def service(): # async for _response in service.listener(): # yield _response -@pytest.mark.gps + @pytest.mark.regular async def test_location_verb(event_loop, service: GPS): msgid = await service.location() resp = await service.afbresponse() assert resp.msgid == msgid -@pytest.mark.gps + @pytest.mark.regular @pytest.mark.xfail(reason='expecting this to fail because of "No 3D GNSS fix" and GPS is unavailable') async def test_location_result(event_loop, service: GPS): @@ -44,7 +44,6 @@ async def test_location_result(event_loop, service: GPS): assert resp.status == 'success' -@pytest.mark.gps @pytest.mark.regular async def test_subscribe_verb(event_loop, service: GPS): msgid = await service.subscribe() @@ -53,7 +52,6 @@ async def test_subscribe_verb(event_loop, service: GPS): assert resp.status == 'success' -@pytest.mark.gps @pytest.mark.regular @pytest.mark.dependency async def test_enable_recording(event_loop, service: GPS): @@ -62,7 +60,6 @@ async def test_enable_recording(event_loop, service: GPS): assert resp.status == 'success', resp.info -@pytest.mark.gps @pytest.mark.regular @pytest.mark.dependency(depends=['test_enable_recording']) async def test_disable_recording(event_loop, service: GPS): @@ -71,7 +68,7 @@ async def test_disable_recording(event_loop, service: GPS): assert resp.status == 'success', resp.info -@pytest.mark.gps + @pytest.mark.regular @pytest.mark.dependency async def test_subscribe_location(event_loop, service: GPS): @@ -80,7 +77,7 @@ async def test_subscribe_location(event_loop, service: GPS): assert resp.msgid == msgid assert resp.status == 'success' -@pytest.mark.gps + @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_subscribe_location']) @pytest.mark.xfail # expecting this to fail because of "No 3D GNSS fix" and GPS is unavailable @@ -99,7 +96,6 @@ async def test_location_events(event_loop, service: GPS): pytest.xfail("Did not receive location event") -@pytest.mark.gps @pytest.mark.regular async def test_unsubscribe(event_loop, service: GPS): msgid = await service.unsubscribe('location') diff --git a/pyagl/tests/test_mediascanner.py b/pyagl/tests/test_mediascanner.py index 33ef004..2ca10cc 100644 --- a/pyagl/tests/test_mediascanner.py +++ b/pyagl/tests/test_mediascanner.py @@ -5,7 +5,7 @@ import logging from pyagl.services.base import AFBResponse, AFBT from pyagl.services.mediascanner import MediaScannerService as mss -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.mediascanner] events = ['media_added', 'media_removed'] @pytest.fixture(scope='module') @@ -24,7 +24,6 @@ async def service(): @pytest.mark.regular -@pytest.mark.mediascanner async def test_media_result(event_loop, service: mss): msgid = await service.media_result() resp = await service.afbresponse() @@ -32,7 +31,6 @@ async def test_media_result(event_loop, service: mss): @pytest.mark.regular -@pytest.mark.mediascanner async def test_subscribe(event_loop, service: mss): for e in events: msgid = await service.subscribe(e) @@ -41,7 +39,6 @@ async def test_subscribe(event_loop, service: mss): @pytest.mark.regular -@pytest.mark.mediascanner async def test_unsubscribe(event_loop, service: mss): for e in events: msgid = await service.unsubscribe(e) diff --git a/pyagl/tests/test_network.py b/pyagl/tests/test_network.py index 5ac2630..53653cf 100644 --- a/pyagl/tests/test_network.py +++ b/pyagl/tests/test_network.py @@ -5,7 +5,7 @@ import logging from pyagl.services.base import AFBResponse, AFBT from pyagl.services.network import NetworkService as NS -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.network] @pytest.fixture(scope='module') @@ -29,7 +29,6 @@ def expected_available_techs(): return techs -@pytest.mark.network @pytest.mark.regular async def test_state(event_loop, service: NS): msgid = await service.state() @@ -38,7 +37,6 @@ async def test_state(event_loop, service: NS): assert resp.data == 'online' -@pytest.mark.network @pytest.mark.regular async def test_global_offline(event_loop, service: NS): addr, _ = service.websocket.remote_address @@ -50,7 +48,6 @@ async def test_global_offline(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_scan_services(event_loop, service: NS, expected_available_techs): scannable_techs = ['wifi', 'bluetooth'] @@ -61,7 +58,6 @@ async def test_scan_services(event_loop, service: NS, expected_available_techs): assert resp.status == 'success', f'scan_services failed for technology {t} - {resp.info}' -@pytest.mark.network @pytest.mark.regular async def test_global_online(event_loop, service: NS): msgid = await service.offline(False) @@ -69,7 +65,6 @@ async def test_global_online(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular @pytest.mark.dependency async def test_technologies_verb(event_loop, service: NS): @@ -79,7 +74,6 @@ async def test_technologies_verb(event_loop, service: NS): assert 'values' in resp.data -@pytest.mark.network @pytest.mark.regular @pytest.mark.dependency(depends=['test_technologies_verb']) async def test_expected_existing_technologies(event_loop, service: NS, expected_available_techs): @@ -90,7 +84,6 @@ async def test_expected_existing_technologies(event_loop, service: NS, expected_ assert t in techs, f'"{t}" technology is expected to be available, but it is not' -@pytest.mark.network @pytest.mark.regular @pytest.mark.dependency(depends=['test_expected_existing_technologies']) async def test_get_property(event_loop, service: NS, expected_available_techs): @@ -105,7 +98,6 @@ async def test_get_property(event_loop, service: NS, expected_available_techs): assert len(diverging_fields) == 0, f'the following property fields are diverging from the expected: {diverging_fields}' -@pytest.mark.network @pytest.mark.regular @pytest.mark.xfail(reason='Expecting this to throw "permission denied" via the API, tethering from connmanctl succeeds') async def test_enable_wifi_tethering(event_loop, service: NS, expected_available_techs): @@ -118,7 +110,6 @@ async def test_enable_wifi_tethering(event_loop, service: NS, expected_available assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular @pytest.mark.dependency(depends='test_enable_wifi_tethering') async def test_disable_wifi_tethering(event_loop, service: NS, expected_available_techs): @@ -129,7 +120,7 @@ async def test_disable_wifi_tethering(event_loop, service: NS, expected_availabl assert resp.status == 'success', resp.info -#@pytest.mark.network +# #@pytest.mark.regular # async def test_set_property(event_loop, service: NS, expected_available_techs): # for t in expected_available_techs: @@ -139,7 +130,6 @@ async def test_disable_wifi_tethering(event_loop, service: NS, expected_availabl # print(resp) -@pytest.mark.network @pytest.mark.regular async def test_services_verb(event_loop, service: NS): msgid = await service.services() @@ -148,7 +138,6 @@ async def test_services_verb(event_loop, service: NS): assert 'values' in resp.data -@pytest.mark.network @pytest.mark.regular async def test_subscribe_global_state(event_loop, service: NS): msgid = await service.subscribe('global_state') @@ -156,7 +145,6 @@ async def test_subscribe_global_state(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_unsubscribe_global_state(event_loop, service: NS): msgid = await service.unsubscribe('global_state') @@ -164,7 +152,6 @@ async def test_unsubscribe_global_state(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_subscribe_technologies(event_loop, service: NS): msgid = await service.subscribe('technologies') @@ -172,7 +159,6 @@ async def test_subscribe_technologies(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_unsubscribe_technologies(event_loop, service: NS): msgid = await service.unsubscribe('technologies') @@ -180,7 +166,6 @@ async def test_unsubscribe_technologies(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_subscribe_tech_props(event_loop, service: NS): msgid = await service.subscribe('technology_properties') @@ -188,7 +173,6 @@ async def test_subscribe_tech_props(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_unsubscribe_tech_props(event_loop, service: NS): msgid = await service.unsubscribe('technology_properties') @@ -196,7 +180,6 @@ async def test_unsubscribe_tech_props(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_subscribe_services(event_loop, service: NS): msgid = await service.subscribe('services') @@ -204,7 +187,6 @@ async def test_subscribe_services(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_unsubscribe_services(event_loop, service: NS): msgid = await service.unsubscribe('services') @@ -212,7 +194,6 @@ async def test_unsubscribe_services(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_subscribe_service_props(event_loop, service: NS): msgid = await service.subscribe('service_properties') @@ -220,7 +201,6 @@ async def test_subscribe_service_props(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_unsubscribe_service_props(event_loop, service: NS): msgid = await service.unsubscribe('service_properties') @@ -228,7 +208,6 @@ async def test_unsubscribe_service_props(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_subscribe_agent(event_loop, service: NS): msgid = await service.subscribe('agent') @@ -236,7 +215,6 @@ async def test_subscribe_agent(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_unsubscribe_agent(event_loop, service: NS): msgid = await service.unsubscribe('agent') @@ -244,7 +222,6 @@ async def test_unsubscribe_agent(event_loop, service: NS): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_enable_wifi(event_loop, service: NS, expected_available_techs): if 'wifi' not in expected_available_techs: @@ -254,7 +231,6 @@ async def test_enable_wifi(event_loop, service: NS, expected_available_techs): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_disable_wifi(event_loop, service: NS, expected_available_techs): if 'wifi' not in expected_available_techs: @@ -264,7 +240,6 @@ async def test_disable_wifi(event_loop, service: NS, expected_available_techs): assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_enable_bluetooth(event_loop, service: NS, expected_available_techs): if 'bluetooth' not in expected_available_techs: @@ -274,7 +249,6 @@ async def test_enable_bluetooth(event_loop, service: NS, expected_available_tech assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_disable_bluetooth(event_loop, service: NS, expected_available_techs): if 'bluetooth' not in expected_available_techs: @@ -284,7 +258,6 @@ async def test_disable_bluetooth(event_loop, service: NS, expected_available_tec assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_enable_ethernet(event_loop, service: NS, expected_available_techs): if 'ethernet' not in expected_available_techs: @@ -294,7 +267,6 @@ async def test_enable_ethernet(event_loop, service: NS, expected_available_techs assert resp.status == 'success', resp.info -@pytest.mark.network @pytest.mark.regular async def test_disable_ethernet(event_loop, service: NS, expected_available_techs): addr, _ = service.websocket.remote_address diff --git a/pyagl/tests/test_nfc.py b/pyagl/tests/test_nfc.py index b845b8d..4695295 100644 --- a/pyagl/tests/test_nfc.py +++ b/pyagl/tests/test_nfc.py @@ -6,7 +6,7 @@ from pyagl.services.base import AFBResponse, AFBT from concurrent.futures import TimeoutError from pyagl.services.nfc import NFCService as nfcs -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.nfc] @pytest.fixture(scope='module') @@ -24,7 +24,6 @@ async def service(): await svc.websocket.close() -@pytest.mark.nfc @pytest.mark.regular async def subscribe(event_loop, service: nfcs): msgid = service.subscribe() @@ -32,7 +31,6 @@ async def subscribe(event_loop, service: nfcs): assert resp.msgid == msgid -@pytest.mark.nfc @pytest.mark.regular async def unsubscribe(event_loop, service: nfcs): msgid = service.unsubscribe() diff --git a/pyagl/tests/test_weather.py b/pyagl/tests/test_weather.py index 1a5e204..c83a2fa 100644 --- a/pyagl/tests/test_weather.py +++ b/pyagl/tests/test_weather.py @@ -5,7 +5,7 @@ import logging from pyagl.services.base import AFBResponse, AFBT from pyagl.services.weather import WeatherService as ws -pytestmark = pytest.mark.asyncio +pytestmark = [pytest.mark.asyncio, pytest.mark.weather, pytest.mark.regular] @pytest.fixture(scope='module') @@ -23,8 +23,6 @@ async def service(): await gpss.websocket.close() -@pytest.mark.weather -@pytest.mark.regular async def test_apikey(event_loop, service: ws): msgid = await service.apikey() resp = await service.afbresponse() @@ -32,8 +30,6 @@ async def test_apikey(event_loop, service: ws): assert resp.data['api_key'] == 'a860fa437924aec3d0360cc749e25f0e' -@pytest.mark.weather -@pytest.mark.regular async def test_current_weather(event_loop, service: ws): msgid = await service.current_weather() resp = await service.afbresponse() @@ -41,24 +37,18 @@ async def test_current_weather(event_loop, service: ws): assert 'sys' in resp.data -@pytest.mark.weather -@pytest.mark.regular async def test_bad_subscription(event_loop, service: ws): msgid = await service.subscribe('non-existant') resp = await service.afbresponse() assert resp.status == 'failed' -@pytest.mark.weather -@pytest.mark.regular async def test_bad_unsubscription(event_loop, service: ws): msgid = await service.unsubscribe('non-existant') resp = await service.afbresponse() assert resp.status == 'failed' -@pytest.mark.weather -@pytest.mark.regular @pytest.mark.dependency async def test_subscribe_weather(event_loop, service: ws): event = 'weather' @@ -69,8 +59,6 @@ async def test_subscribe_weather(event_loop, service: ws): assert eventresp.api == f'{service.api}/{event}' -@pytest.mark.weather -@pytest.mark.regular @pytest.mark.dependency(depends=['test_subscribe_weather']) async def test_unsubscribe_weather(event_loop, service: ws): msgid = await service.subscribe('weather') |