82f69c39785dd61407b65f714db54f069fab818d
[dcaegen2/platform.git] / adapter / acumos / tests / test_validatejson.py
1 # ============LICENSE_START====================================================
2 # org.onap.dcae
3 # =============================================================================
4 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
5 # =============================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END======================================================
18
19 """
20 Test the compatibility of Adapter while reading metadata from both previous (upto Clio) Acumos releases
21 and the new Demeter release.
22 """
23
24 import aoconversion
25 import testing_helpers
26
27
28 def test_validate_format_Clio():
29     """
30     Given the metadata as per Acumos Clio's tree structure, check if the validate_json method
31     reads the correct input and output name
32     """
33     model_repo_path = testing_helpers.get_fixture_path('models')
34     model_name = 'example-model'
35     meta = aoconversion.utils.get_metadata(model_repo_path, model_name)
36
37     for method in meta["methods"]:
38         assert (aoconversion.utils.validate_format(meta, method, "input")) == "NumbersIn"
39         assert (aoconversion.utils.validate_format(meta, method, "output")) == "NumberOut"
40
41
42 def test_validate_format_Demeter():
43     """
44         Given the metadata as per Acumos Clio's tree structure, check if the validate_json method
45         can also read the correct input and output name without fail
46         """
47     model_repo_path = testing_helpers.get_fixture_path('models')
48     model_name = 'example-model-demeter'
49     meta = aoconversion.utils.get_metadata(model_repo_path, model_name)
50
51     for method in meta["methods"]:
52         assert (aoconversion.utils.validate_format(meta, method, "input")) == "NumbersIn"
53         assert (aoconversion.utils.validate_format(meta, method, "output")) == "NumbersOut"