Add dcae-cli and component-json-schemas projects
[dcaegen2/platform/cli.git] / dcae-cli / dcae_cli / util / tests / test_docker_util.py
1 # ============LICENSE_START=======================================================
2 # org.onap.dcae
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
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 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
20
21 # -*- coding: utf-8 -*-
22 '''
23 Provides tests for the docker_util module
24 '''
25 import pytest
26 from dcae_cli.util.profiles import Profile, CONSUL_HOST, CONFIG_BINDING_SERVICE, CDAP_BROKER, DOCKER_HOST
27 from dcae_cli.util import docker_util as du
28
29
30 # TODO: formalize tests
31 '''
32 from dcae_cli.util.logger import set_verbose
33 set_verbose()
34
35 client = _get_docker_client()
36
37 params = dict()
38 interface_map = dict()
39 instance_map = dict()
40 # TODO: make-me-valid?
41 external_ip ='196.207.143.209'
42
43 # TODO: Need to replace the use of asimov
44 _run_component('asimov-anomaly-viz:0.0.0',
45                'bob', 'asimov.anomaly.viz', '1.0.0', params, interface_map, instance_map,
46                external_ip)
47 '''
48
49 def test_convert_profile_to_docker_envs():
50     expected = { CONSUL_HOST.upper(): "some.consul.somewhere",
51                  CONFIG_BINDING_SERVICE.upper(): "some.config_binding.somewhere",
52                  CDAP_BROKER.upper(): "broker",
53                  DOCKER_HOST.upper(): "some-docker-host"
54                }
55     profile = Profile(**{ CONSUL_HOST: expected[CONSUL_HOST.upper()],
56                           CONFIG_BINDING_SERVICE: expected[CONFIG_BINDING_SERVICE.upper()],
57                           CDAP_BROKER: expected[CDAP_BROKER.upper()],
58                           DOCKER_HOST: expected[DOCKER_HOST.upper()]
59                         })
60     actual = du._convert_profile_to_docker_envs(profile)
61
62     assert actual == expected