1 # ==================================================================================
2 # Copyright (c) 2019 Nokia
3 # Copyright (c) 2018-2019 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 # ==================================================================================
19 from a1 import utils, exceptions
20 import testing_helpers
23 def test_bad_get_ric_manifest(monkeypatch):
25 testing missing manifest
28 def badopen(filename, mode):
29 raise FileNotFoundError()
31 monkeypatch.setattr("builtins.open", badopen)
32 with pytest.raises(exceptions.MissingManifest):
33 utils.get_ric_manifest()
36 def test_good_get_ric_manifest(monkeypatch):
40 testing_helpers.patch_all(monkeypatch)
41 utils.get_ric_manifest()
44 def test_validate(monkeypatch):
46 test json validation wrapper
48 testing_helpers.patch_all(monkeypatch)
49 ricmanifest = utils.get_ric_manifest()
50 schema = ricmanifest["controls"][0]["message_receives_payload_schema"]
51 utils.validate_json(testing_helpers.good_payload(), schema)
52 with pytest.raises(jsonschema.exceptions.ValidationError):
53 utils.validate_json({"dc_admission_start_time": "10:00:00", "dc_admission_end_time": "nevergonnagiveyouup"}, schema)