summaryrefslogtreecommitdiffstats
path: root/dcae-cli/dcae_cli/util/tests
diff options
context:
space:
mode:
Diffstat (limited to 'dcae-cli/dcae_cli/util/tests')
-rw-r--r--dcae-cli/dcae_cli/util/tests/test_config.py21
-rw-r--r--dcae-cli/dcae_cli/util/tests/test_discovery.py15
-rw-r--r--dcae-cli/dcae_cli/util/tests/test_profiles.py10
3 files changed, 17 insertions, 29 deletions
diff --git a/dcae-cli/dcae_cli/util/tests/test_config.py b/dcae-cli/dcae_cli/util/tests/test_config.py
index 97be773..82f0679 100644
--- a/dcae-cli/dcae_cli/util/tests/test_config.py
+++ b/dcae-cli/dcae_cli/util/tests/test_config.py
@@ -59,31 +59,34 @@ def test_init_config_user(monkeypatch):
def test_init_config(monkeypatch):
monkeypatch.setattr(config, '_init_config_user', lambda: "bigmama")
- monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_nexus',
- lambda path: { "db_url": "conn" })
+ monkeypatch.setattr(config, '_init_config_server_url',
+ lambda: "http://some-nexus-in-the-sky.com")
+ monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web',
+ lambda server_url, path: { "db_url": "conn" })
monkeypatch.setattr("dcae_cli._version.__version__", "2.X.X")
- expected = {'cli_version': '2.X.X', 'user': 'bigmama', 'db_url': 'conn'}
+ expected = {'cli_version': '2.X.X', 'user': 'bigmama', 'db_url': 'conn',
+ 'server_url': 'http://some-nexus-in-the-sky.com'}
assert expected == config._init_config()
# Test using of db fallback
- monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_nexus',
- lambda path: { "db_url": "" })
+ monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web',
+ lambda server_url, path: { "db_url": "" })
assert "sqlite" in config._init_config()["db_url"]
- monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_nexus',
- lambda path: {})
+ monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web',
+ lambda server_url, path: {})
assert "sqlite" in config._init_config()["db_url"]
# Simulate error trying to fetch
- def fetch_simulate_error(path):
+ def fetch_simulate_error(server_url, path):
raise RuntimeError("Simulated error")
- monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_nexus',
+ monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web',
fetch_simulate_error)
with pytest.raises(config.ConfigurationInitError):
diff --git a/dcae-cli/dcae_cli/util/tests/test_discovery.py b/dcae-cli/dcae_cli/util/tests/test_discovery.py
index aed5ca8..0832c5e 100644
--- a/dcae-cli/dcae_cli/util/tests/test_discovery.py
+++ b/dcae-cli/dcae_cli/util/tests/test_discovery.py
@@ -373,21 +373,6 @@ def test_make_instance_map():
instances_map = dis._make_instances_map(instances_latest_format)
assert instances_map.get(("sandbox.platform.laika", "0.5.0")) == set(instances_latest_format)
- instances_other_format = ["mike.39f809be-7d13-4799-b8d0-ba0d5358282b.0-5-0.sandbox-platform-laika.rework-central.dcae.com"]
-
- instances_map = dis._make_instances_map(instances_other_format)
- assert instances_map.get(("sandbox.platform.laika", "0.5.0")) == set(instances_other_format)
-
- instances_other_format = ["mike.b5435a8c-ef56-4371-94d8-560a61f7352f.0-5-0.sandbox-platform-laika.solutioning-central.dcae.com"]
-
- instances_map = dis._make_instances_map(instances_other_format)
- assert instances_map.get(("sandbox.platform.laika", "0.5.0")) == set(instances_other_format)
-
- instances_other_format = ["mike.b5435a8c-ef56-4371-94d8-560a61f7352f.0-5-0.sandbox-platform-laika.dcae.com"]
-
- instances_map = dis._make_instances_map(instances_other_format)
- assert instances_map.get(("sandbox.platform.laika", "0.5.0")) == set(instances_other_format)
-
def test_get_component_instances(monkeypatch):
instances = [
diff --git a/dcae-cli/dcae_cli/util/tests/test_profiles.py b/dcae-cli/dcae_cli/util/tests/test_profiles.py
index 2d809f5..b15d9b5 100644
--- a/dcae-cli/dcae_cli/util/tests/test_profiles.py
+++ b/dcae-cli/dcae_cli/util/tests/test_profiles.py
@@ -122,10 +122,10 @@ def test_reinit_profiles(monkeypatch, tmpdir):
"consul_host": "realsolcnsl00.dcae.solutioning.com",
"docker_host": "realsoldokr00.dcae.solutioning.com:2376" }}
- def fetch_profile(target_profile, path):
+ def fetch_profile(target_profile, server_url, path):
return target_profile
- monkeypatch.setattr(util, "fetch_file_from_nexus", partial(fetch_profile,
+ monkeypatch.setattr(util, "fetch_file_from_web", partial(fetch_profile,
profile_dict))
profiles.reinit_profiles()
assert profiles.get_profiles(include_active=False) == profile_dict
@@ -137,7 +137,7 @@ def test_reinit_profiles(monkeypatch, tmpdir):
"consul_host": "realsolcnsl00.dcae.solutioning.com",
"docker_host": "realsoldokr00.dcae.solutioning.com:2376" }}
- monkeypatch.setattr(util, "fetch_file_from_nexus", partial(fetch_profile,
+ monkeypatch.setattr(util, "fetch_file_from_web", partial(fetch_profile,
profile_dict))
profiles.reinit_profiles()
all_profiles = profiles.get_profiles(include_active=False)
@@ -146,10 +146,10 @@ def test_reinit_profiles(monkeypatch, tmpdir):
# Test fetch failure
- def fetch_failure(path):
+ def fetch_failure(server_url, path):
raise RuntimeError("Mysterious error")
- monkeypatch.setattr(util, "fetch_file_from_nexus", fetch_failure)
+ monkeypatch.setattr(util, "fetch_file_from_web", fetch_failure)
with pytest.raises(profiles.ProfilesInitError):
profiles.reinit_profiles()