diff options
author | Michael Hwang <mhwang@research.att.com> | 2017-09-22 10:05:05 -0400 |
---|---|---|
committer | Michael Hwang <mhwang@research.att.com> | 2017-09-22 13:04:33 -0400 |
commit | af7747ca4a7d849dbef9f86b31216e388334f876 (patch) | |
tree | fecec814a0cf8e03689aa399c322eb499d6437c1 /dcae-cli/dcae_cli | |
parent | f9b3a97cc69baa4be00c9d054ce7b6cd1cfeee53 (diff) |
Get tox working
* Use public onap dependencies
* Make to work with tox
* Fix unit tests
Change-Id: I08ed9fa33003f4ec017818f61acf83b9f29ec9a3
Issue-Id: DCAEGEN2-60
Signed-off-by: Michael Hwang <mhwang@research.att.com>
Diffstat (limited to 'dcae-cli/dcae_cli')
-rw-r--r-- | dcae-cli/dcae_cli/util/tests/test_config.py | 17 | ||||
-rw-r--r-- | dcae-cli/dcae_cli/util/tests/test_profiles.py | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/dcae-cli/dcae_cli/util/tests/test_config.py b/dcae-cli/dcae_cli/util/tests/test_config.py index 82f0679..3b4cd6e 100644 --- a/dcae-cli/dcae_cli/util/tests/test_config.py +++ b/dcae-cli/dcae_cli/util/tests/test_config.py @@ -66,7 +66,8 @@ def test_init_config(monkeypatch): monkeypatch.setattr("dcae_cli._version.__version__", "2.X.X") expected = {'cli_version': '2.X.X', 'user': 'bigmama', 'db_url': 'conn', - 'server_url': 'http://some-nexus-in-the-sky.com'} + 'server_url': 'http://some-nexus-in-the-sky.com', + 'active_profile': 'default' } assert expected == config._init_config() # Test using of db fallback @@ -74,12 +75,20 @@ def test_init_config(monkeypatch): monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web', lambda server_url, path: { "db_url": "" }) - assert "sqlite" in config._init_config()["db_url"] + db_url = "postgresql://king:of@mountain:5432/dcae_onboarding_db" + + def fake_init_config_db_url(): + return db_url + + monkeypatch.setattr(config, "_init_config_db_url", + fake_init_config_db_url) + + assert db_url == config._init_config()["db_url"] monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web', lambda server_url, path: {}) - assert "sqlite" in config._init_config()["db_url"] + assert db_url == config._init_config()["db_url"] # Simulate error trying to fetch @@ -88,6 +97,8 @@ def test_init_config(monkeypatch): monkeypatch.setattr(dcae_cli.util, 'fetch_file_from_web', fetch_simulate_error) + # Case when user opts out of manually setting up + monkeypatch.setattr(click, "confirm", lambda msg: False) with pytest.raises(config.ConfigurationInitError): config._init_config() diff --git a/dcae-cli/dcae_cli/util/tests/test_profiles.py b/dcae-cli/dcae_cli/util/tests/test_profiles.py index b15d9b5..969697a 100644 --- a/dcae-cli/dcae_cli/util/tests/test_profiles.py +++ b/dcae-cli/dcae_cli/util/tests/test_profiles.py @@ -150,6 +150,8 @@ def test_reinit_profiles(monkeypatch, tmpdir): raise RuntimeError("Mysterious error") monkeypatch.setattr(util, "fetch_file_from_web", fetch_failure) + # Case when user opts out of manually setting up + monkeypatch.setattr(click, "confirm", lambda msg: False) with pytest.raises(profiles.ProfilesInitError): profiles.reinit_profiles() |