Extract ocloud integration test
[pti/o2.git] / tests / integration-ocloud / test_clientdriver_stx_sa.py
1 # Copyright (C) 2021 Wind River Systems, Inc.\r
2 #\r
3 #  Licensed under the Apache License, Version 2.0 (the "License");\r
4 #  you may not use this file except in compliance with the License.\r
5 #  You may obtain a copy of the License at\r
6 #\r
7 #      http://www.apache.org/licenses/LICENSE-2.0\r
8 #\r
9 #  Unless required by applicable law or agreed to in writing, software\r
10 #  distributed under the License is distributed on an "AS IS" BASIS,\r
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 #  See the License for the specific language governing permissions and\r
13 #  limitations under the License.\r
14 \r
15 import sys\r
16 import pytest\r
17 from o2ims.adapter import ocloud_repository as repository\r
18 from o2ims.domain import ocloud\r
19 from o2ims import config\r
20 import uuid\r
21 from o2ims.adapter.clients.ocloud_sa_client import StxSaClientImp\r
22 from cgtsclient.client import get_client\r
23 \r
24 import logging\r
25 \r
26 \r
27 @pytest.fixture\r
28 def real_stx_aio_client():\r
29     os_client_args = config.get_stx_access_info()\r
30     config_client = get_client(**os_client_args)\r
31     yield config_client\r
32 \r
33 # pytestmark = pytest.mark.usefixtures("mappers")\r
34 \r
35 \r
36 def test_get_instanceinfo(real_stx_aio_client):\r
37     logger = logging.getLogger(__name__)\r
38     stxclientimp = StxSaClientImp(real_stx_aio_client)\r
39     assert stxclientimp is not None\r
40     systeminfo = stxclientimp.getInstanceInfo()\r
41     assert systeminfo is not None\r
42     assert systeminfo.id is not None\r
43     assert systeminfo.name is not None\r
44     assert systeminfo.content is not None\r
45 \r
46 \r
47 def test_get_pserverlist(real_stx_aio_client):\r
48     stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
49     assert stxSaClientImp is not None\r
50     hosts = stxSaClientImp.getPserverList()\r
51     assert hosts is not None\r
52     assert len(hosts) > 0\r
53 \r
54 \r
55 def test_get_pserver(real_stx_aio_client):\r
56     stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
57     assert stxSaClientImp is not None\r
58     hosts = stxSaClientImp.getPserverList()\r
59     assert hosts is not None\r
60     assert len(hosts) > 0\r
61     host1 = hosts[0]\r
62     host2 = stxSaClientImp.getPserver(host1.id)\r
63     assert host1 != host2\r
64     assert host1.id == host2.id\r