Add tox support
This commit is contained in:
parent
87e0f9112a
commit
0b2168037a
@ -1,5 +1,5 @@
|
||||
.project
|
||||
.pydevproject
|
||||
bin
|
||||
.coveragerc
|
||||
.coverage
|
||||
.testrepository
|
||||
.tox
|
||||
tags
|
||||
|
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
|
11
requirements.txt
Normal file
11
requirements.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# 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
|
8
test-requirements.txt
Normal file
8
test-requirements.txt
Normal file
@ -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
|
29
tox.ini
Normal file
29
tox.ini
Normal file
@ -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
|
@ -85,7 +85,7 @@ class CephRadosGWTests(CharmTestCase):
|
||||
self.test_config.set('use-ceph-optimised-packages', '')
|
||||
ceph_hooks.install_packages()
|
||||
self.add_source.assert_called_with('distro', 'secretkey')
|
||||
self.apt_update.assert_called()
|
||||
self.assertTrue(self.apt_update.called)
|
||||
self.apt_install.assert_called_with(['libapache2-mod-fastcgi',
|
||||
'apache2'], fatal=True)
|
||||
|
||||
@ -95,8 +95,8 @@ class CephRadosGWTests(CharmTestCase):
|
||||
_install_packages = self.patch('install_ceph_optimised_packages')
|
||||
ceph_hooks.install_packages()
|
||||
self.add_source.assert_called_with('distro', 'secretkey')
|
||||
self.apt_update.assert_called()
|
||||
_install_packages.assert_called()
|
||||
self.assertTrue(self.apt_update.called)
|
||||
self.assertTrue(_install_packages.called)
|
||||
self.apt_install.assert_called_with(['libapache2-mod-fastcgi',
|
||||
'apache2'], fatal=True)
|
||||
|
||||
@ -106,8 +106,8 @@ class CephRadosGWTests(CharmTestCase):
|
||||
_install_packages = self.patch('install_ceph_optimised_packages')
|
||||
ceph_hooks.install_packages()
|
||||
self.add_source.assert_called_with('distro', 'secretkey')
|
||||
self.apt_update.assert_called()
|
||||
_install_packages.assert_called()
|
||||
self.assertTrue(self.apt_update.called)
|
||||
self.assertFalse(_install_packages.called)
|
||||
self.apt_install.assert_called_with(['radosgw',
|
||||
'ntp',
|
||||
'haproxy'], fatal=True)
|
||||
@ -117,8 +117,8 @@ class CephRadosGWTests(CharmTestCase):
|
||||
def test_install(self):
|
||||
_install_packages = self.patch('install_packages')
|
||||
ceph_hooks.install()
|
||||
self.execd_preinstall.assert_called()
|
||||
_install_packages.assert_called()
|
||||
self.assertTrue(self.execd_preinstall.called)
|
||||
self.assertTrue(_install_packages.called)
|
||||
self.enable_pocket.assert_called_with('multiverse')
|
||||
self.os.makedirs.called_with('/var/lib/ceph/nss')
|
||||
|
||||
@ -175,20 +175,20 @@ class CephRadosGWTests(CharmTestCase):
|
||||
_apache_modules = self.patch('apache_modules')
|
||||
_apache_reload = self.patch('apache_reload')
|
||||
ceph_hooks.config_changed()
|
||||
_install_packages.assert_called()
|
||||
self.assertTrue(_install_packages.called)
|
||||
self.CONFIGS.write_all.assert_called_with()
|
||||
_emit_apacheconf.assert_called()
|
||||
_install_www_scripts.assert_called()
|
||||
_apache_sites.assert_called()
|
||||
_apache_modules.assert_called()
|
||||
_apache_reload.assert_called()
|
||||
self.assertTrue(_emit_apacheconf.called)
|
||||
self.assertTrue(_install_www_scripts.called)
|
||||
self.assertTrue(_apache_sites.called)
|
||||
self.assertTrue(_apache_modules.called)
|
||||
self.assertTrue(_apache_reload.called)
|
||||
|
||||
def test_mon_relation(self):
|
||||
_ceph = self.patch('ceph')
|
||||
_restart = self.patch('restart')
|
||||
self.relation_get.return_value = 'seckey'
|
||||
ceph_hooks.mon_relation()
|
||||
_restart.assert_called()
|
||||
self.assertTrue(_restart.called)
|
||||
_ceph.import_radosgw_key.assert_called_with('seckey')
|
||||
self.CONFIGS.write_all.assert_called_with()
|
||||
|
||||
@ -275,7 +275,7 @@ class CephRadosGWTests(CharmTestCase):
|
||||
_restart = self.patch('restart')
|
||||
ceph_hooks.identity_changed()
|
||||
self.CONFIGS.write_all.assert_called_with()
|
||||
_restart.assert_called()
|
||||
self.assertTrue(_restart.called)
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.ip.is_clustered')
|
||||
@patch('charmhelpers.contrib.openstack.ip.unit_get')
|
||||
|
Loading…
Reference in New Issue
Block a user