diff --git a/.bzrignore b/.bzrignore index a742d5a9..9ad1b67f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,4 +1,5 @@ -revision 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/hooks/keystone_ssl.py b/hooks/keystone_ssl.py index fc4513c8..e7b0870c 100644 --- a/hooks/keystone_ssl.py +++ b/hooks/keystone_ssl.py @@ -323,7 +323,7 @@ class JujuCA(object): @property def ca_key_path(self): - return os.path.join(self.ca_dir, 'private', 'cacert.key') + return os.path.join(self.ca_dir, 'private', 'cacert.key') @property def root_ca_cert_path(self): @@ -331,7 +331,7 @@ class JujuCA(object): @property def root_ca_key_path(self): - return os.path.join(self.root_ca_dir, 'private', 'cacert.key') + return os.path.join(self.root_ca_dir, 'private', 'cacert.key') def get_ca_bundle(self): int_cert = open(self.ca_cert_path).read() diff --git a/hooks/keystone_utils.py b/hooks/keystone_utils.py index 31bb9baf..87e71b76 100644 --- a/hooks/keystone_utils.py +++ b/hooks/keystone_utils.py @@ -372,7 +372,7 @@ def save_script_rc(): def do_openstack_upgrade_reexec(configs): do_openstack_upgrade(configs) - log("Re-execing hook to pickup upgraded packages", level=INFO) + log("Re-execing hook to pickup upgraded packages", level=INFO) os.execl('./hooks/config-changed-postupgrade', '') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..db0dfb3b --- /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-keystoneclient>=1.6.0,!=1.8.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/tox.ini b/tox.ini new file mode 100644 index 00000000..4e328e48 --- /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 + 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 6deaf82a..7ffe5afe 100644 --- a/unit_tests/test_actions_git_reinstall.py +++ b/unit_tests/test_actions_git_reinstall.py @@ -1,11 +1,7 @@ from mock import patch -with patch('charmhelpers.core.hookenv.config') as config: - config.return_value = 'keystone' - import keystone_utils as utils # noqa - - with patch('keystone_utils.register_configs') as register_configs: - import git_reinstall +with patch('hooks.keystone_utils.register_configs') as register_configs: + import git_reinstall from test_utils import ( CharmTestCase