4219f66cef6249f3f7239ee2c8f50a0df19f33fc
[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 # =============================================================================
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 import os
20 import pytest
21 import requests
22
23 import aoconversion
24 from tests import testing_helpers
25
26
27 @pytest.fixture
28 def mock_schemas(monkeypatch):
29     cwd = os.getcwd()
30     schemadir = cwd[:cwd.find('/adapter/acumos')] + '/mod/component-json-schemas'
31     monkeypatch.setattr(aoconversion.utils.component_schema, 'path', schemadir + '/component-specification/dcae-cli-v2/component-spec-schema.json')
32     monkeypatch.setattr(aoconversion.utils.dataformat_schema, 'path', schemadir + '/data-format/dcae-cli-v1/data-format-schema.json')
33     monkeypatch.setattr(aoconversion.utils.schema_schema, 'ret', requests.get('https://json-schema.org/draft-04/schema#').json())
34
35
36 def test_get_metadata():
37     model_repo_path = testing_helpers.get_fixture_path('models')
38     model_name = 'example-model'
39     assert (aoconversion.utils.get_metadata(model_repo_path, model_name) == {
40         "schema": "acumos.schema.model:0.4.0",
41         "runtime": {
42             "name": "python",
43             "encoding": "protobuf",
44             "version": "3.6.8",
45             "dependencies": {
46                 "pip": {
47                     "indexes": [],
48                     "requirements": [
49                         {
50                             "name": "dill",
51                             "version": "0.3.0"
52                         },
53                         {
54                             "name": "acumos",
55                             "version": "0.8.0"
56                         }
57                     ]
58                 },
59                 "conda": {
60                     "channels": [],
61                     "requirements": []
62                 }
63             }
64         },
65         "name": "example-model",
66         "methods": {
67             "add": {
68                 "input": "NumbersIn",
69                 "output": "NumberOut",
70                 "description": "Adds two integers"
71             }
72         }
73     })