From 91d8d103827e54289e2925b15e0329e965f64be5 Mon Sep 17 00:00:00 2001 From: Ryan Beisner Date: Mon, 28 Nov 2016 18:20:43 -0600 Subject: [PATCH] Update tox.ini for py27 requirement Reactive source charms are Python3-only, but have py27 unit tests declared in project-config. The Tox tool recently changed behavior. It used to pass when a tox target was missing commands. Now it fails in that case. This commit places a py27 no-op shim to allow gate tests to pass, effectively restoring the original behavior for these py3x-only repos. Fix unit tests after underlying changes in charms.openstack which set_config_defined_certs_and_keys and added oncigure_source to the default install method. Change-Id: I82445240c49a2d58c6eb39da4f49d21350d8d8b4 Partial-Bug: 1642981 --- src/lib/charm/openstack/aodh.py | 8 -------- tox.ini | 10 +++++++++- unit_tests/test_lib_charm_openstack_aodh.py | 10 ---------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/lib/charm/openstack/aodh.py b/src/lib/charm/openstack/aodh.py index d4e03e3..9d6b1f1 100644 --- a/src/lib/charm/openstack/aodh.py +++ b/src/lib/charm/openstack/aodh.py @@ -114,14 +114,6 @@ class AodhCharm(charms_openstack.charm.HAOpenStackCharm): release = ch_utils.os_release('python-keystonemiddleware') super(AodhCharm, self).__init__(release=release, **kwargs) - def install(self): - """Customise the installation, configure the source and then call the - parent install() method to install the packages - """ - self.configure_source() - # and do the actual install - super(AodhCharm, self).install() - def install(): """Use the singleton from the AodhCharm to install the packages on the diff --git a/tox.ini b/tox.ini index 893f30f..3ba2b23 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,14 @@ basepython = python2.7 commands = charm-build --log-level DEBUG -o {toxinidir}/build src {posargs} +[testenv:py27] +basepython = python2.7 +# Reactive source charms are Python3-only, but a py27 unit test target +# is required by OpenStack Governance. Remove this shim as soon as +# permitted. http://governance.openstack.org/reference/cti/python_cti.html +whitelist_externals = true +commands = true + [testenv:py34] basepython = python3.4 deps = -r{toxinidir}/test-requirements.txt @@ -35,7 +43,7 @@ deps = -r{toxinidir}/test-requirements.txt commands = ostestr {posargs} [testenv:pep8] -basepython = python2.7 +basepython = python3.5 deps = -r{toxinidir}/test-requirements.txt commands = flake8 {posargs} src unit_tests diff --git a/unit_tests/test_lib_charm_openstack_aodh.py b/unit_tests/test_lib_charm_openstack_aodh.py index fa6b14c..674aa38 100644 --- a/unit_tests/test_lib_charm_openstack_aodh.py +++ b/unit_tests/test_lib_charm_openstack_aodh.py @@ -47,15 +47,11 @@ class Helper(unittest.TestCase): class TestOpenStackAodh(Helper): def test_install(self): - self.patch(aodh.AodhCharm, - 'set_config_defined_certs_and_keys') self.patch(aodh.AodhCharm.singleton, 'install') aodh.install() self.install.assert_called_once_with() def test_setup_endpoint(self): - self.patch(aodh.AodhCharm, - 'set_config_defined_certs_and_keys') self.patch(aodh.AodhCharm, 'service_name', new_callable=mock.PropertyMock) self.patch(aodh.AodhCharm, 'region', @@ -77,8 +73,6 @@ class TestOpenStackAodh(Helper): 'type1', 'region1', 'public_url', 'internal_url', 'admin_url') def test_render_configs(self): - self.patch(aodh.AodhCharm, - 'set_config_defined_certs_and_keys') self.patch(aodh.AodhCharm.singleton, 'render_with_interfaces') aodh.render_configs('interfaces-list') self.render_with_interfaces.assert_called_once_with( @@ -123,15 +117,11 @@ class TestAodhAdapters(Helper): class TestAodhCharm(Helper): def test__init__(self): - self.patch(aodh.AodhCharm, - 'set_config_defined_certs_and_keys') self.patch(aodh.ch_utils, 'os_release') aodh.AodhCharm() self.os_release.assert_called_once_with('python-keystonemiddleware') def test_install(self): - self.patch(aodh.AodhCharm, - 'set_config_defined_certs_and_keys') b = aodh.AodhCharm() self.patch(aodh.charms_openstack.charm.OpenStackCharm, 'configure_source')