Mock snap_install_requested in unit tests

Unit test for layered charms fail due to the new snap support.
snap_install_requested must be mocked out.

Change-Id: Id2e10f436300813a6c223ef4148cd82bd6f46ba5
Closes-Bug: #1722587
This commit is contained in:
David Ames 2017-10-11 19:00:26 +00:00
parent b4a2fb2bf8
commit a780e72d81
3 changed files with 7 additions and 1 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ interfaces
.testrepository
*__pycache__*
*.pyc
.stestr

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=./unit_tests
top_dir=./

View File

@ -88,13 +88,14 @@ class TestKeystoneLDAPCharm(Helper):
self.assertEqual('/etc/keystone/domains/keystone.userdomain.conf',
charm.configuration_file)
@mock.patch('charmhelpers.contrib.openstack.utils.snap_install_requested')
@mock.patch('charmhelpers.core.hookenv.config')
@mock.patch('charmhelpers.core.hookenv.status_set')
@mock.patch('charmhelpers.core.hookenv.application_version_set')
def test_assess_status(self,
application_version_set,
status_set,
config):
config, snap_install_requested):
reply = {
'ldap-server': 'myserver',
'ldap-user': 'myusername',
@ -108,6 +109,7 @@ class TestKeystoneLDAPCharm(Helper):
return reply
config.side_effect = mock_config
snap_install_requested.return_value = False
# Check that active status is set correctly
keystone_ldap.assess_status()
status_set.assert_called_with('active', mock.ANY)