Browse Source

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
changes/23/511323/2
David Ames 2 years ago
parent
commit
a780e72d81
3 changed files with 7 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +3
    -0
      .stestr.conf
  3. +3
    -1
      unit_tests/test_lib_charm_openstack_keystone_ldap.py

+ 1
- 0
.gitignore View File

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

+ 3
- 0
.stestr.conf View File

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

+ 3
- 1
unit_tests/test_lib_charm_openstack_keystone_ldap.py 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)


Loading…
Cancel
Save