diff --git a/.bzrignore b/.bzrignore index 5a2cffa7..e408deae 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,3 +1,5 @@ .coverage bin tags +.tox +.testrepository diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..801646bb --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ ./unit_tests $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/requirements/requirements-precise.txt b/requirements/requirements-precise.txt new file mode 100644 index 00000000..21ee7d12 --- /dev/null +++ b/requirements/requirements-precise.txt @@ -0,0 +1,6 @@ +PyYAML==3.10 +simplejson==2.3.2 +netifaces==0.8 +netaddr==0.7.10 +Jinja2==2.6 +six==1.1.0 diff --git a/requirements/requirements-trusty.txt b/requirements/requirements-trusty.txt new file mode 100644 index 00000000..e292ca25 --- /dev/null +++ b/requirements/requirements-trusty.txt @@ -0,0 +1,6 @@ +PyYAML>=3.10 +simplejson==3.3.1 +netifaces==0.8 +netaddr==0.7.10 +Jinja2==2.7.2 +six==1.5.2 diff --git a/requirements/test-requirements.txt b/requirements/test-requirements.txt new file mode 100644 index 00000000..ffefe42b --- /dev/null +++ b/requirements/test-requirements.txt @@ -0,0 +1,7 @@ +testtools==0.9.35 +coverage==3.7.1 +mock==1.0.1 +flake8==2.1.0 +# No version required +charm-tools +os-testr diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 4a47e614..c49452f5 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -361,7 +361,7 @@ class GlanceBasicDeployment(OpenStackAmuletDeployment): expected['keystone_authtoken'].update({ 'auth_host': rel_ks_gl['auth_host'], 'auth_port': rel_ks_gl['auth_port'], - 'auth_protocol': rel_ks_gl['auth_protocol'] + 'auth_protocol': rel_ks_gl['auth_protocol'] }) return expected diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..428bd6f8 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +# Default to current LTS +envlist = lint,py27-trusty +skipsdist = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +install_command = + pip install --allow-unverified python-apt {opts} {packages} +commands = ostestr {posargs} + +[testenv:py27-precise] +basepython = python2.7 +deps = -r{toxinidir}/requirements/requirements-precise.txt + -r{toxinidir}/requirements/test-requirements.txt + +[testenv:py27-trusty] +basepython = python2.7 +deps = -r{toxinidir}/requirements/requirements-trusty.txt + -r{toxinidir}/requirements/test-requirements.txt + +[testenv:lint] +basepython = python2.7 +deps = -r{toxinidir}/requirements/requirements-trusty.txt + -r{toxinidir}/requirements/test-requirements.txt +commands = flake8 {posargs} actions hooks unit_tests tests + charm proof + +[testenv:venv] +commands = {posargs} + +[flake8] +ignore = E402,E226 +exclude = hooks/charmhelpers diff --git a/unit_tests/test_actions_git_reinstall.py b/unit_tests/test_actions_git_reinstall.py index 84e79c5c..8c7196d6 100644 --- a/unit_tests/test_actions_git_reinstall.py +++ b/unit_tests/test_actions_git_reinstall.py @@ -13,6 +13,7 @@ from test_utils import ( TO_PATCH = [ 'config', + 'git_install_requested', ] @@ -31,6 +32,7 @@ class TestGlanceActions(CharmTestCase): def setUp(self): super(TestGlanceActions, self).setUp(git_reinstall, TO_PATCH) self.config.side_effect = self.test_config.get + self.git_install_requested.return_value = True @patch.object(git_reinstall, 'action_set') @patch.object(git_reinstall, 'action_fail') @@ -56,6 +58,7 @@ class TestGlanceActions(CharmTestCase): def test_git_reinstall_not_configured(self, config_changed, git_install, action_fail, action_set): config.return_value = None + self.git_install_requested.return_value = False git_reinstall.git_reinstall() diff --git a/unit_tests/test_actions_openstack_upgrade.py b/unit_tests/test_actions_openstack_upgrade.py index 1e11b25e..854332e7 100644 --- a/unit_tests/test_actions_openstack_upgrade.py +++ b/unit_tests/test_actions_openstack_upgrade.py @@ -12,7 +12,8 @@ from test_utils import ( ) TO_PATCH = [ - 'config' + 'config', + 'git_install_requested', ] @@ -22,6 +23,7 @@ class TestGlanceUpgradeActions(CharmTestCase): super(TestGlanceUpgradeActions, self).setUp(openstack_upgrade, TO_PATCH) self.config.side_effect = self.test_config.get + self.git_install_requested.return_value = False @patch.object(openstack_upgrade, 'action_set') @patch.object(openstack_upgrade, 'action_fail')