X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tests%2Ftesting_helpers.py;fp=tests%2Ftesting_helpers.py;h=3cf94e256d77cc8771e70b661a9ab7fbe8cd72cf;hb=5ad8f03e1fc7683bb59da31f59edc2f6c0b2372b;hp=0000000000000000000000000000000000000000;hpb=d36a35ba53b3d805cb73eda3d72af946ed977f16;p=ric-plt%2Fa1.git diff --git a/tests/testing_helpers.py b/tests/testing_helpers.py new file mode 100644 index 0000000..3cf94e2 --- /dev/null +++ b/tests/testing_helpers.py @@ -0,0 +1,42 @@ +# ================================================================================== +# Copyright (c) 2019 Nokia +# Copyright (c) 2018-2019 AT&T Intellectual Property. +# +# 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 json +import os +from rmr.rmr_mocks import rmr_mocks + + +def _get_fixture_path(name): + cur_dir = os.path.dirname(os.path.realpath(__file__)) + return "{0}/fixtures/{1}".format(cur_dir, name) + + +def patch_all(monkeypatch, nonexisting_rmr=False): + rmr_mocks.patch_rmr(monkeypatch) + + # patch manifest + man = json.loads(open(_get_fixture_path("ricmanifest.json"), "r").read()) + if nonexisting_rmr: + man["controls"][0]["message_receives_rmr_type"] = "DARKNESS" + monkeypatch.setattr("a1.utils.get_ric_manifest", lambda: man) + + # patch rmr mapping + mapping = open(_get_fixture_path("rmr_string_int_mapping.txt"), "r").readlines() + monkeypatch.setattr("a1.utils._get_rmr_mapping_table", lambda: mapping) + + +def good_payload(): + return {"dc_admission_start_time": "10:00:00", "dc_admission_end_time": "11:00:00"}