summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorduerpei <duep.fnst@fujitsu.com>2021-09-24 12:40:27 +0800
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2021-11-18 11:55:24 +0000
commita85181feb25871846d4c47f812659b1cd064e341 (patch)
tree2882509de817cba4884ad36b8af13310488fd704
parent6e4d0fc065173ba7e356563a8bf176bd502642c6 (diff)
Add testcases to agl-service-network module
Bug-AGL:SPEC-4069 Signed-off-by: duerpei <duep.fnst@fujitsu.com> Change-Id: I1d0e84e9cfde529868d8153e6b6a2e4b7794c2d8
-rw-r--r--pyagl/services/network.py2
-rw-r--r--pyagl/tests/test_network.py46
2 files changed, 47 insertions, 1 deletions
diff --git a/pyagl/services/network.py b/pyagl/services/network.py
index 8eae084..09867c2 100644
--- a/pyagl/services/network.py
+++ b/pyagl/services/network.py
@@ -27,7 +27,7 @@ class NetworkService(AGLBaseService):
parser.add_argument('--services', action='store_true')
def __init__(self, ip, port=None, service='agl-service-network'):
- super().__init__(api='network-manager', ip=ip, port=port, service=service)
+ super().__init__(api='network-manager', ip=ip, port=port, service=service, timeout = 20)
async def state(self):
return await self.request('state')
diff --git a/pyagl/tests/test_network.py b/pyagl/tests/test_network.py
index ca6d1f5..931fddd 100644
--- a/pyagl/tests/test_network.py
+++ b/pyagl/tests/test_network.py
@@ -49,6 +49,26 @@ def scannable_interfaces():
scannable = os.environ.get('AGL_SCANNABLE_INTERFACES', 'wifi,bluetooth').split(',')
+@pytest.fixture()
+async def get_wifi_name(event_loop, service: NS):
+ #get a name_string of a wifi service
+ wifi_name = os.environ.get('AGL_TEST_WIFI_SSID')
+ if not wifi_name:
+ pytest.xfail('Please export AGL_TEST_WIFI_SSID with valid wifi name to run the test.'
+ 'The value of it might look like: wifi_dca6323a2b94_4368696e614e6574_managed_xxx')
+ #Check if the wifi is in the current list
+ msgid = await service.services()
+ resp = await service.afbresponse()
+ data = resp.data
+ t_values = data['values']
+ for ser in t_values:
+ service = ser['service']
+ if service == wifi_name:
+ return wifi_name
+
+ pytest.skip('the service is not in the list')
+
+
async def test_state(event_loop, service: NS):
msgid = await service.state()
resp = await service.afbresponse()
@@ -272,4 +292,30 @@ async def test_unsubscribe_agent(event_loop, service: NS):
assert resp.status == 'success', resp.info
+async def test_scan_wifi(event_loop, service: NS):
+ msgid = await service.scan_services('wifi')
+ resp = await service.afbresponse()
+ if 'No carrier' in resp.info:
+ pytest.xfail('scan wifi services not success,you can try it again')
+ assert resp.status == 'success'
+
+
+async def test_connect_service_wifi(event_loop, service: NS, get_wifi_name):
+ wifi_name = get_wifi_name
+ msgid = await service.connect_service(wifi_name)
+ resp = await service.afbresponse()
+ assert resp.status == 'success' or resp.info == 'Connect error: GDBus.Error:net.connman.Error.AlreadyConnected: Already connected'
+
+async def test_disconnect_service_wifi(event_loop, service: NS, get_wifi_name):
+ wifi_name = get_wifi_name
+ msgid = await service.disconnect_service(wifi_name)
+ resp = await service.afbresponse()
+ assert resp.status == 'success' or resp.info == 'Disconnect error Not connected'
+
+
+async def test_remove_service_wifi(event_loop, service: NS, get_wifi_name):
+ wifi_name = get_wifi_name
+ msgid = await service.remove_service(wifi_name)
+ resp = await service.afbresponse()
+ assert resp.status == 'success'