blob: e62281adb518f2448cd14f7aaed724a7eca97035 [file] [log] [blame]
Lott, Christopher (cl778h)db26ba22020-04-09 18:25:19 -04001# =================================================================================2
2# Copyright (c) 2019-2020 Nokia
3# Copyright (c) 2018-2020 AT&T Intellectual Property.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ==================================================================================
17from ricxappframe.rmr.rmrclib import rmrclib
18
19
20def test_get_constants(expected_constants):
21 """
22 test getting constants. We don't care what values are returned as those
23 should be meaningful only to RMR. We do care that all of the constants
24 which are defined in expected_contents are returned. Further, we don't
25 consider it to be an error if the returned list has more constants than
26 what are in our list.
27
28 To avoid frustration, this should list all missing keys, not fail on the
29 first missing key.
30 """
31 errors = 0
32 econst = expected_constants
33 rconst = rmrclib.get_constants()
34 for key in econst: # test all expected constants
35 if key not in rconst: # expected value not listed by rmr
36 errors += 1
37 print("did not find required constant in list from RMR: %s" % key)
38
39 assert errors == 0
40
41
42def test_get_mapping_dict(expected_states):
43 """
44 test getting mapping string
45 """
46 assert rmrclib.get_mapping_dict() == expected_states
47 assert rmrclib.state_to_status(0) == "RMR_OK"
Lott, Christopher (cl778h)61270902020-05-06 09:23:55 -040048 assert rmrclib.state_to_status(2) == "RMR_ERR_NOENDPT"
49 assert rmrclib.state_to_status(10) == "RMR_ERR_RETRY"
Lott, Christopher (cl778h)db26ba22020-04-09 18:25:19 -040050 assert rmrclib.state_to_status(12) == "RMR_ERR_TIMEOUT"
51 assert rmrclib.state_to_status(666) == "UNKNOWN STATE"