1 # Copyright (C) 2022 Wind River Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 from o2common.config import config
20 from o2ims.adapter.clients.fault_client import StxFaultClientImp
21 # from o2ims.adapter.clients.ocloud_client import StxClientImp
22 from cgtsclient.client import get_client as get_stx_client
23 from dcmanagerclient.api.client import client as get_dc_client
24 from fmclient.client import get_client as get_fm_client
28 def real_stx_aio_client():
29 os_client_args = config.get_stx_access_info()
30 config_client = get_stx_client(**os_client_args)
35 def real_stx_dc_client():
36 os_client_args = config.get_dc_access_info()
37 config_client = get_dc_client(**os_client_args)
42 def real_stx_fm_client():
43 os_client_args = config.get_fm_access_info()
44 config_client = get_fm_client(1, **os_client_args)
47 # pytestmark = pytest.mark.usefixtures("mappers")
50 def test_get_alarmlist(real_stx_fm_client):
51 fmClientImp = StxFaultClientImp(real_stx_fm_client)
52 assert fmClientImp is not None
53 alarms = fmClientImp.getAlarmList()
54 assert alarms is not None
55 assert len(alarms) > 0
58 def test_get_alarminfo(real_stx_fm_client):
59 fmClientImp = StxFaultClientImp(real_stx_fm_client)
60 assert fmClientImp is not None
61 alarms = fmClientImp.getAlarmList()
62 assert alarms is not None
63 assert len(alarms) > 0
65 alarm2 = fmClientImp.getAlarmInfo(alarm1.id)
66 assert alarm1 != alarm2
67 assert alarm1.id == alarm2.id
68 # fmClientImp.getAlarmInfo('f87478e9-4cec-44dc-8f13-9304445d4070')
69 # assert fmClientImp is None
72 def test_get_eventlist(real_stx_fm_client):
73 fmClientImp = StxFaultClientImp(real_stx_fm_client)
74 assert fmClientImp is not None
75 events = fmClientImp.getEventList()
76 assert events is not None
77 assert len(events) > 0
80 def test_get_eventinfo(real_stx_fm_client):
81 fmClientImp = StxFaultClientImp(real_stx_fm_client)
82 assert fmClientImp is not None
83 events = fmClientImp.getEventList()
84 assert events is not None
85 assert len(events) > 0
87 event2 = fmClientImp.getEventInfo(event1.id)
88 assert event1 != event2
89 assert event1.id == event2.id