From 0379ccb303b69f5b09ed1396b32b98d31a45ce31 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 2 Nov 2015 09:28:57 +0000 Subject: [PATCH] Add tox support --- .bzrignore | 2 ++ .testr.conf | 8 +++++++ requirements.txt | 12 +++++++++++ test-requirements.txt | 8 +++++++ tests/basic_deployment.py | 2 +- tox.ini | 29 ++++++++++++++++++++++++++ unit_tests/test_neutron_api_context.py | 2 +- 7 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .testr.conf create mode 100644 requirements.txt create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.bzrignore b/.bzrignore index 421e2bda..9ad1b67f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,3 +1,5 @@ bin .coverage +.testrepository +.tox tags 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.txt b/requirements.txt new file mode 100644 index 00000000..2cc5f64a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +PyYAML>=3.1.0 +simplejson>=2.2.0 +netifaces>=0.10.4 +netaddr>=0.7.12,!=0.7.16 +Jinja2>=2.6 # BSD License (3 clause) +six>=1.9.0 +dnspython>=1.12.0 +psutil>=1.1.1,<2.0.0 +python-neutronclient>=2.6.0 diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..3af44d73 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,8 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +coverage>=3.6 +mock>=1.2 +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 +charm-tools diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 2a3472d8..5efc9810 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -466,7 +466,7 @@ class NeutronAPIBasicDeployment(OpenStackAmuletDeployment): 'service_port': rel_napi_ks['service_port'], 'auth_host': rel_napi_ks['auth_host'], 'auth_port': rel_napi_ks['auth_port'], - 'auth_protocol': rel_napi_ks['auth_protocol'] + 'auth_protocol': rel_napi_ks['auth_protocol'] }) for section, pairs in expected.iteritems(): diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..a79b65dc --- /dev/null +++ b/tox.ini @@ -0,0 +1,29 @@ +[tox] +envlist = lint,py27 +skipsdist = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +install_command = + pip install --allow-unverified python-apt {opts} {packages} +commands = ostestr {posargs} + +[testenv:py27] +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:lint] +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = flake8 {posargs} hooks unit_tests tests actions + charm proof + +[testenv:venv] +commands = {posargs} + +[flake8] +ignore = E402,E226 +exclude = hooks/charmhelpers diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 0b9127d7..00979047 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -217,7 +217,7 @@ class HAProxyContextTest(CharmTestCase): @patch('__builtin__.__import__') @patch('__builtin__.open') def test_context_peers(self, _open, _import, _log, _rids, _runits, _rget, - _uget, _lunit, _config, _get_address_in_network, + _uget, _lunit, _config, _get_address_in_network, _get_netmask_for_address): unit_addresses = { 'neutron-api-0': '10.10.10.10',