1 # =================================================================================2
2 # Copyright (c) 2019-2020 Nokia
3 # Copyright (c) 2018-2020 AT&T Intellectual Property.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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 # ==================================================================================
17 from ricxappframe.rmr.rmrclib import rmrclib
20 def test_get_constants(expected_constants):
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
28 To avoid frustration, this should list all missing keys, not fail on the
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
37 print("did not find required constant in list from RMR: %s" % key)
42 def test_get_mapping_dict(expected_states):
44 test getting mapping string
46 assert rmrclib.get_mapping_dict() == expected_states
47 assert rmrclib.state_to_status(0) == "RMR_OK"
48 assert rmrclib.state_to_status(2) == "RMR_ERR_NOENDPT"
49 assert rmrclib.state_to_status(10) == "RMR_ERR_RETRY"
50 assert rmrclib.state_to_status(12) == "RMR_ERR_TIMEOUT"
51 assert rmrclib.state_to_status(666) == "UNKNOWN STATE"