aboutsummaryrefslogtreecommitdiffstats
path: root/pyagl/tests/test_taskmanager.py
diff options
context:
space:
mode:
authorliuyahui <liuyh.fnst@fujitsu.com>2021-06-02 12:44:44 +0800
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2021-06-04 08:33:12 +0000
commit9f132032cd2896cc4024cac7e7a481baad7a920e (patch)
tree79a236f4add4c5583eda237efb66b2c3f0d103fe /pyagl/tests/test_taskmanager.py
parentb1e192d43258d370460bd882230584116cacf8d1 (diff)
Add main function to taskmanager service module
and add pytest python script to taskmanager service module Bug-AGL: SPEC-3946 Signed-off-by: liuyahui <liuyh.fnst@fujitsu.com> Change-Id: I403c7004d87bc4f3171363a678a8d50a5fa50aca
Diffstat (limited to 'pyagl/tests/test_taskmanager.py')
-rw-r--r--pyagl/tests/test_taskmanager.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/pyagl/tests/test_taskmanager.py b/pyagl/tests/test_taskmanager.py
new file mode 100644
index 0000000..10c1855
--- /dev/null
+++ b/pyagl/tests/test_taskmanager.py
@@ -0,0 +1,54 @@
+# Copyright (C) 2021 Fujitsu
+# Author: liu yahui
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import asyncio
+import os
+import pytest
+import logging
+from pyagl.services.base import AFBResponse, AFBT
+from pyagl.services.taskmanager import TaskManagerService as TASK
+
+pytestmark = [pytest.mark.asyncio, pytest.mark.taskmanager]
+
+@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)
+ tasks = await TASK(ip=address, port=port)
+ yield tasks
+ await tasks.websocket.close()
+
+
+async def test_get_process_list(event_loop, service: TASK):
+ msgid = await service.get_process_list()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+
+async def test_get_netstat(event_loop, service: TASK):
+ msgid = await service.get_netstat()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+
+async def test_get_load_avg(event_loop, service: TASK):
+ msgid = await service.get_load_avg()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'