1 # ============LICENSE_START=======================================================
3 # ================================================================================
4 # Copyright (c) 2017 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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
19 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 from dcae_cli.util.cdap_util import _merge_spec_config_into_broker_put, normalize_cdap_params
24 def test_normalize_cdap_params():
25 spec = {"parameters" : {}}
26 normalized = normalize_cdap_params(spec)
27 assert normalized == {"app_preferences" : {},
29 "program_preferences" : []}
33 Tests both _merge_spec_config_into_broker_put and normalize_cdap_params
35 jar = "bahphomet.com/nexus/doomsday.jar"
37 "artifact_name" : "testname",
38 "artifact_version" : "6.6.6",
39 "streamname" : "stream",
40 "programs" : [{"program_type" : "flows", "program_id" : "flow_id"}],
41 "namespace" : "underworld"
46 "description": "description",
47 "component_type": "cdap",
51 "app_preferences" : [{"name" : "he", "description" : "", "value" : "shall rise"}],
52 "program_preferences" : [{"program_type" : "flows", "program_id" : "flow_id", "program_pref" : [{"name": "foo", "description" : "", "value" : "bar"}]}]
62 {"request": {"format" : 'std.format_one', "version" : "1.0.0"},
63 "response" : {"format" : "std.format_two", "version" : "1.5.0"},
64 "service_name" : "baphomet",
65 "service_endpoint" : "rises",
70 parsed_parameters = normalize_cdap_params(spec)
71 templated_conf = {"streams_publishes":{}, "streams_subscribes": {},
72 "services_calls": {}} #TODO: Incorporate a test templated_conf
73 broker_put = _merge_spec_config_into_broker_put(jar, config, spec, parsed_parameters, templated_conf)
76 "app_config": {"services_calls" : {},
77 "streams_publishes" : {},
78 "streams_subscribes": {}
80 "app_preferences": {"he" : "shall rise"},
81 "artifact_name" : "testname",
82 "artifact_version" : "6.6.6",
83 "jar_url": "bahphomet.com/nexus/doomsday.jar",
84 "namespace": "underworld",
85 "program_preferences" : [{"program_type" : "flows", "program_id" : "flow_id", "program_pref" : {"foo" : "bar"}}],
86 "programs" : [{"program_type" : "flows", "program_id" : "flow_id"}],
87 "service_component_type": "cdap",
88 "services": [{"service_name" : "baphomet", "service_endpoint" : "rises", "endpoint_method" : "GET"}],
89 "streamname": "stream",
90 "cdap_application_type" : "program-flowlet"
93 assert broker_put == expected