diff options
-rw-r--r-- | pyagl/services/bluetooth_pbap.py | 16 | ||||
-rw-r--r-- | pyagl/tests/test_bluetooth_pbap.py | 11 |
2 files changed, 20 insertions, 7 deletions
diff --git a/pyagl/services/bluetooth_pbap.py b/pyagl/services/bluetooth_pbap.py index aa7fabf..d4aa9a0 100644 --- a/pyagl/services/bluetooth_pbap.py +++ b/pyagl/services/bluetooth_pbap.py @@ -25,9 +25,10 @@ class BTPBAPService(AGLBaseService): service = 'agl-service-bluetooth-pbap' parser = AGLBaseService.getparser() - parser.add_argument('--import_contacts', action='store_true') + parser.add_argument('--import_contacts', type=int) parser.add_argument('--status', action='store_true') parser.add_argument('--contacts', action='store_true') + parser.add_argument('--search', type=str,help='search telephone number') parser.add_argument('--history', choices=['ich','och','mch','cch'], help='Request call history - Incoming/Outgoing' '/Missed/Combined calls') @@ -38,10 +39,10 @@ class BTPBAPService(AGLBaseService): return await super().subscribe(event) async def unsubscribe(self, event='status'): - return await super().subscribe(event) + return await super().unsubscribe(event) - async def import_contacts(self): - return await super().request('import') + async def import_contacts(self, max_entries): + return await super().request('import',{'max_entries': max_entries}) async def status(self): return await super().request('status') @@ -65,8 +66,13 @@ async def main(loop): if args.loglevel: svc.logger.setLevel(args.loglevel) + if args.search: + msgid= await svc.search(number=args.search) + print(f'Sent search request with messageid {msgid}') + print(await svc.afbresponse()) + if args.import_contacts: - msgid = await svc.import_contacts() + msgid = await svc.import_contacts(max_entries=args.import_contacts) print(f'Sent import_contacts request with messageid {msgid}') resp = await svc.afbresponse() if resp.status == 'success': diff --git a/pyagl/tests/test_bluetooth_pbap.py b/pyagl/tests/test_bluetooth_pbap.py index 61883f6..cc8612e 100644 --- a/pyagl/tests/test_bluetooth_pbap.py +++ b/pyagl/tests/test_bluetooth_pbap.py @@ -57,6 +57,13 @@ def searchvcf(): return vcf +@pytest.fixture(scope='module') +def contact_count(): + contact_count =3 + + return contact_count + + @pytest.mark.dependency async def test_status(event_loop, service: PBAP): @@ -79,8 +86,8 @@ async def test_search(event_loop, service: PBAP, phonenumber): @pytest.mark.hwrequired @pytest.mark.dependency(depends=['test_status']) -async def test_import_contacts(event_loop, service: PBAP): - msgid = await service.import_contacts() +async def test_import_contacts(event_loop, service: PBAP,contact_count): + msgid = await service.import_contacts(contact_count) resp = await service.afbresponse() assert resp.status == 'success' assert 'vcards' in resp.data |