Add support for lint and testing using tox
This commit is contained in:
parent
b2875098fc
commit
4caa6fd031
@ -1,3 +1,5 @@
|
||||
.coverage
|
||||
bin
|
||||
tags
|
||||
.tox
|
||||
.testrepository
|
||||
|
8
.testr.conf
Normal file
8
.testr.conf
Normal file
@ -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
|
6
requirements/requirements-precise.txt
Normal file
6
requirements/requirements-precise.txt
Normal file
@ -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
|
6
requirements/requirements-trusty.txt
Normal file
6
requirements/requirements-trusty.txt
Normal file
@ -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
|
7
requirements/test-requirements.txt
Normal file
7
requirements/test-requirements.txt
Normal file
@ -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
|
35
tox.ini
Normal file
35
tox.ini
Normal file
@ -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
|
@ -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()
|
||||
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user