Acumos Adapter updates to support v3 schema
[dcaegen2/platform.git] / adapter / acumos / tests / conftest.py
1 # ============LICENSE_START====================================================
2 # org.onap.dcae
3 # =============================================================================
4 # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
5 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
6 # =============================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END======================================================
19
20 import os
21 import pytest
22 import requests
23
24 import aoconversion
25 from tests import testing_helpers
26
27
28 @pytest.fixture
29 def mock_schemas(monkeypatch):
30     cwd = os.getcwd()
31     schemadir = cwd[:cwd.find('/adapter/acumos')] + '/mod/component-json-schemas'
32     monkeypatch.setattr(aoconversion.utils.component_schema, 'path', schemadir + '/component-specification/dcae-cli-v3/component-spec-schema.json')
33     monkeypatch.setattr(aoconversion.utils.dataformat_schema, 'path', schemadir + '/data-format/dcae-cli-v1/data-format-schema.json')
34     monkeypatch.setattr(aoconversion.utils.schema_schema, 'ret', requests.get('https://json-schema.org/draft-04/schema#').json())
35
36
37 def test_get_metadata():
38     model_repo_path = testing_helpers.get_fixture_path('models')
39     model_name = 'example-model'
40     assert (aoconversion.utils.get_metadata(model_repo_path, model_name) == {
41         "schema": "acumos.schema.model:0.4.0",
42         "runtime": {
43             "name": "python",
44             "encoding": "protobuf",
45             "version": "3.6.8",
46             "dependencies": {
47                 "pip": {
48                     "indexes": [],
49                     "requirements": [
50                         {
51                             "name": "dill",
52                             "version": "0.3.0"
53                         },
54                         {
55                             "name": "acumos",
56                             "version": "0.8.0"
57                         }
58                     ]
59                 },
60                 "conda": {
61                     "channels": [],
62                     "requirements": []
63                 }
64             }
65         },
66         "name": "example-model",
67         "methods": {
68             "add": {
69                 "input": "NumbersIn",
70                 "output": "NumberOut",
71                 "description": "Adds two integers"
72             }
73         }
74     })