diff options
author | shi ce <shic.fnst@fujitsu.com> | 2021-06-02 10:45:37 +0800 |
---|---|---|
committer | shi ce <shic.fnst@fujitsu.com> | 2021-06-02 10:45:37 +0800 |
commit | 1eecf421a71d9cb6a264860d38c4e6a5b4131a78 (patch) | |
tree | 792d33023aa9483ad72068ef4cb9157314206f41 | |
parent | 137a32d3b0068e2141ed9aab23d8a8956c0cb094 (diff) |
update bluetooth_pbap binding and tests
Add the search interface tests and modified the 'super().subscribe' to
'super().unsubscribe'.
in addition, fix the import_contacts interface tests failed when run by
pytest test_bluetooth_pbap.py
Bug-AGL: SPEC-3919
Signed-off-by: shi ce <shic.fnst@fujitsu.com>
Change-Id: I2d658b90820d9d5bcf6f222633804aa801910f37
-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 |