Make tox work in a fresh scenario
[dcaegen2/platform/cli.git] / dcae-cli / dcae_cli / conftest.py
1 # ============LICENSE_START=======================================================
2 # org.onap.dcae
3 # ================================================================================
4 # Copyright (c) 2018 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 This module is actually for pytesting. This contains fixtures.
22 """
23
24 import pytest
25 import dcae_cli
26
27 # REVIEW: Having issues trying to share this amongst all the tests. Putting this
28 # fixture here allows it to be shared when running tests over the entire project.
29 # The pytest recommendation was to place this file high up in the project.
30
31 @pytest.fixture
32 def mock_cli_config(monkeypatch):
33     """Fixture to provide a mock dcae-cli configuration and profiles
34
35     This fixture monkeypatches the respective get calls to return mock objects
36     """
37     fake_config = { "active_profile": "default", "user": "bob",
38             "server_url": "https://git.onap.org/dcaegen2/platform/cli/plain",
39             "db_url": "postgresql://postgres:abc123@localhost:5432/dcae_onboarding_db"
40             }
41
42     fake_profiles = { "default": { "consul_host": "consul",
43         "cdap_broker": "cdap_broker",
44         "config_binding_service": "config_binding_service",
45         "docker_host": "docker_host" }
46         }
47     fake_profiles["active"] = fake_profiles["default"]
48
49     def fake_get_config():
50         return fake_config
51
52     def fake_get_profiles(user_only=False, include_active=True):
53         return fake_profiles
54
55     from dcae_cli.util import config, profiles
56     monkeypatch.setattr(dcae_cli.util.config, "get_config", fake_get_config)
57     monkeypatch.setattr(dcae_cli.util.profiles, "get_profiles", fake_get_profiles)
58