summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Kavanagh <alex@ajkavanagh.co.uk>2017-05-25 11:19:58 +0100
committerAlex Kavanagh <alex@ajkavanagh.co.uk>2017-05-25 11:22:43 +0100
commit355fc831b77d465a3c980731ecfd10b6e84e19c1 (patch)
tree906a673ef25d797b907a0dccc9868a1124e14774
parentb57040e12a86de5a914124e0ace78a7f132344ca (diff)
downloadcharm-murano-355fc831b77d465a3c980731ecfd10b6e84e19c1.zip
charm-murano-355fc831b77d465a3c980731ecfd10b6e84e19c1.tar.gz
charm-murano-355fc831b77d465a3c980731ecfd10b6e84e19c1.tar.bz2
Use charms.openstack charmhelpers test_mocks
Every reactive charm that uses charms.openstack and implements unit testing needs to mock charmhelpers, as otherwise the tests blow up. This patch uses the mocking of charmhelpers in charms.openstack so that a charm layer can just import test_mocks and charmhelpers will be mocked out along with setting up a default charmhelpers.c.o.u.OPENSTACK_RELEASES so that when an OpenStackCharm() derived charm class won't fail on definition. Change-Id: I489b15301f64310f7077d0e7246fd5e116877ed9 Related-Bug: #1693017 Depends-On: I5ac40617ee30e5f421ec16fc7592177a5e6aa166
-rw-r--r--.gitignore7
-rw-r--r--.gitreview4
-rw-r--r--src/lib/charm/openstack/murano.py2
-rw-r--r--unit_tests/__init__.py28
-rw-r--r--unit_tests/test_lib_charm_openstack_murano.py8
5 files changed, 14 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a0b2628
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+build
+layers
+.tox
+interfaces
+.testrepository
+*__pycache__*
+*.pyc
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..91969e2
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,4 @@
+[gerrit]
+host=review.openstack.org
+port=29418
+project=openstack/charm-murano.git
diff --git a/src/lib/charm/openstack/murano.py b/src/lib/charm/openstack/murano.py
index 6704375..af548b1 100644
--- a/src/lib/charm/openstack/murano.py
+++ b/src/lib/charm/openstack/murano.py
@@ -46,7 +46,7 @@ class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
"""
if release is None:
release = ch_utils.os_release('python-keystonemiddleware')
- super(MuranoCharm, self).__init__(release=release, **kwargs)
+ super().__init__(release=release, **kwargs)
def get_amqp_credentials(self):
"""Provide the default amqp username and vhost as a tuple.
diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py
index 12469eb..3a5e9a3 100644
--- a/unit_tests/__init__.py
+++ b/unit_tests/__init__.py
@@ -13,34 +13,10 @@
# limitations under the License.
import sys
-import mock
sys.path.append('src')
sys.path.append('src/lib')
# Mock out charmhelpers so that we can test without it.
-# also stops sideeffects from occuring.
-charmhelpers = mock.MagicMock()
-apt_pkg = mock.MagicMock()
-sys.modules['apt_pkg'] = apt_pkg
-sys.modules['charmhelpers'] = charmhelpers
-sys.modules['charmhelpers.core'] = charmhelpers.core
-sys.modules['charmhelpers.core.decorators'] = charmhelpers.core.decorators
-sys.modules['charmhelpers.core.hookenv'] = charmhelpers.core.hookenv
-sys.modules['charmhelpers.core.host'] = charmhelpers.core.host
-sys.modules['charmhelpers.core.unitdata'] = charmhelpers.core.unitdata
-sys.modules['charmhelpers.core.templating'] = charmhelpers.core.templating
-sys.modules['charmhelpers.contrib'] = charmhelpers.contrib
-sys.modules['charmhelpers.contrib.openstack'] = charmhelpers.contrib.openstack
-sys.modules['charmhelpers.contrib.openstack.utils'] = (
- charmhelpers.contrib.openstack.utils)
-sys.modules['charmhelpers.contrib.openstack.templating'] = (
- charmhelpers.contrib.openstack.templating)
-sys.modules['charmhelpers.contrib.network'] = charmhelpers.contrib.network
-sys.modules['charmhelpers.contrib.network.ip'] = (
- charmhelpers.contrib.network.ip)
-sys.modules['charmhelpers.fetch'] = charmhelpers.fetch
-sys.modules['charmhelpers.cli'] = charmhelpers.cli
-sys.modules['charmhelpers.contrib.hahelpers'] = charmhelpers.contrib.hahelpers
-sys.modules['charmhelpers.contrib.hahelpers.cluster'] = (
- charmhelpers.contrib.hahelpers.cluster)
+import charms_openstack.test_mocks # noqa
+charms_openstack.test_mocks.mock_charmhelpers()
diff --git a/unit_tests/test_lib_charm_openstack_murano.py b/unit_tests/test_lib_charm_openstack_murano.py
index b200486..692880f 100644
--- a/unit_tests/test_lib_charm_openstack_murano.py
+++ b/unit_tests/test_lib_charm_openstack_murano.py
@@ -72,15 +72,7 @@ class Helper(unittest.TestCase):
class TestMuranoCharm(Helper):
- def test_install(self):
- self.patch(murano.MuranoCharm, 'configure_source')
- a = murano.MuranoCharm(release='mitaka')
- a.install()
- self.configure_source.assert_called_with()
-
def test__init__(self):
- self.patch(murano.MuranoCharm,
- 'set_config_defined_certs_and_keys')
self.patch(murano.ch_utils, 'os_release')
murano.MuranoCharm()
self.os_release.assert_called_once_with('python-keystonemiddleware')

This mirror site include all the OpenStack related repositories under: openstack, openstack-dev and openstack-infra.

NOTE: All repositories are updated every one hour.

Usage

For Git Clone
 git clone http://git.trystack.cn/openstack/nova.git 
For DevStack

Add GIT_BASE, NOVNC_REPO and SPICE_REPO variables to local.conf file.

[[local|localrc]]

# use TryStack git mirror
GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git