1 # ============LICENSE_START====================================================
3 # =============================================================================
4 # Copyright (c) 2019-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
11 # http://www.apache.org/licenses/LICENSE-2.0
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======================================================
20 from testing_helpers import get_json_fixture, get_fixture_path
21 from aoconversion import dataformat_gen, spec_gen, utils
23 TEST_META = get_json_fixture("models/example-model/metadata.json")
26 def test_generate_spec(mock_schemas):
28 Test generating data formats from the protobuf
30 test_proto_path = get_fixture_path("models/example-model/model.proto")
31 data_formats = dataformat_gen._generate_dcae_data_formats(test_proto_path, TEST_META, utils.dataformat_schema.get(),
32 utils.schema_schema.get())
33 assert spec_gen._generate_spec(
34 "example-model", TEST_META, utils.component_schema.get(), data_formats,
39 "name": "example-model",
40 "description": "Automatically generated from Acumos model",
41 "component_type": "docker",
43 "services": {"calls": [], "provides": []},
46 {"config_key": "add_subscriber", "format": "NumbersIn", "version": "1.0.0",
47 "type": "message_router"}
50 {"config_key": "add_publisher", "format": "NumberOut", "version": "1.0.0",
51 "type": "message_router"}
56 "name": "streams_subscribes",
57 "value": "{\"add_subscriber\":{\"dmaap_info\":{\"topic_url\":\"http://message-router:3904/events/unauthenticated.example-model_In\"},\"type\":\"message_router\"}}",
58 "description": "standard http port collector will open for listening;",
59 "sourced_at_deployment": False,
60 "policy_editable": False,
61 "designer_editable": False
64 "name": "streams_publishes",
65 "value": "{\"add_publisher\":{\"dmaap_info\":{\"topic_url\":\"http://message-router:3904/events/unauthenticated.example-model_Out\"},\"type\":\"message_router\"}}",
66 "description": "standard http port collector will open for listening;",
67 "sourced_at_deployment": False,
68 "policy_editable": False,
69 "designer_editable": False
76 "name": "example-model",
77 "has_internal_only_ports": "true",
82 "port_protocol": "http"
87 "healthcheck": {"type": "HTTP", "interval": "15s", "timeout": "1s", "port": 8080,
88 "endpoint": "/healthcheck"}},
89 "artifacts": [{"type": "docker image", "uri": "example-model:latest"}],