summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Hwang <mhwang@research.att.com>2017-09-22 10:05:05 -0400
committerMichael Hwang <mhwang@research.att.com>2017-09-22 13:04:33 -0400
commitaf7747ca4a7d849dbef9f86b31216e388334f876 (patch)
treefecec814a0cf8e03689aa399c322eb499d6437c1
parentf9b3a97cc69baa4be00c9d054ce7b6cd1cfeee53 (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>
-rw-r--r--dcae-cli/.coveragerc21
-rw-r--r--dcae-cli/dcae_cli/util/tests/test_config.py17
-rw-r--r--dcae-cli/dcae_cli/util/tests/test_profiles.py2
-rw-r--r--dcae-cli/requirements.txt5
-rw-r--r--dcae-cli/setup.py7
-rw-r--r--dcae-cli/tox.ini11
6 files changed, 53 insertions, 10 deletions
diff --git a/dcae-cli/.coveragerc b/dcae-cli/.coveragerc
new file mode 100644
index 0000000..088c2da
--- /dev/null
+++ b/dcae-cli/.coveragerc
@@ -0,0 +1,21 @@
+# .coveragerc to control coverage.py
+[run]
+branch = True
+
+[report]
+# Regexes for lines to exclude from consideration
+exclude_lines =
+ # Have to re-enable the standard pragma
+ pragma: no cover
+
+ # Don't complain about missing debug-only code:
+ def __repr__
+ if self\.debug
+
+ # Don't complain if tests don't hit defensive assertion code:
+ raise AssertionError
+ raise NotImplementedError
+
+ # Don't complain if non-runnable code isn't run:
+ if 0:
+ if __name__ == .__main__.:
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()
diff --git a/dcae-cli/requirements.txt b/dcae-cli/requirements.txt
index 52d5aa1..03244e7 100644
--- a/dcae-cli/requirements.txt
+++ b/dcae-cli/requirements.txt
@@ -1,5 +1,4 @@
# TODO: May need to add the following line
-# --extra-index-url <onap pypi url>
python-consul==0.6.1
six==1.10.0
SQLAlchemy==1.1.4
@@ -8,7 +7,7 @@ click==6.6
jsonschema==2.5.1
docker-py==1.10.6
terminaltables==3.1.0
-python-discovery-client==2.0.0
-python-dockering==1.2.1
+onap-dcae-discovery-client==2.1.0
+onap-dcae-dockering==1.3.0
psycopg2==2.7.1
genson==0.2.2
diff --git a/dcae-cli/setup.py b/dcae-cli/setup.py
index 8c6405c..9cfdd3f 100644
--- a/dcae-cli/setup.py
+++ b/dcae-cli/setup.py
@@ -32,7 +32,7 @@ with open(os.path.join(setup_dir, 'dcae_cli', '_version.py')) as file:
setup(
- name = "dcae_cli",
+ name = "onap-dcae-cli",
version = __version__,
packages = find_packages(),
author = "Michael Hwang, Paul Triantafyllou, Tommy Carpenter",
@@ -48,12 +48,11 @@ setup(
'SQLAlchemy-Utils',
'click',
'jsonschema',
- 'docker-py>=1.10,<2',
'terminaltables',
'psycopg2',
'genson',
- 'python-discovery-client>=2.0.0',
- 'python-dockering>=1.0.0,<2.0.0'
+ 'onap-dcae-discovery-client>=2.0.0',
+ 'onap-dcae-dockering>=1.0.0,<2.0.0'
],
tests_require=['pytest',
'mock'],
diff --git a/dcae-cli/tox.ini b/dcae-cli/tox.ini
new file mode 100644
index 0000000..b0f267a
--- /dev/null
+++ b/dcae-cli/tox.ini
@@ -0,0 +1,11 @@
+# content of: tox.ini , put in same dir as setup.py
+[tox]
+envlist = py27,py35
+
+[testenv]
+deps=
+ pytest
+ coverage
+ pytest-cov
+ mock
+commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir}/dcae_cli --cov-report=xml