~openstack-charmers-next/charms/xenial/nova-compute/trunk

« back to all changes in this revision

Viewing changes to unit_tests/test_actions_git_reinstall.py

  • Committer: Edward Hope-Morley
  • Date: 2016-03-24 11:18:41 UTC
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: edward.hope-morley@canonical.com-20160324111841-99ruo5hjzrpqktlx
Add hardening support

Add charmhelpers.contrib.hardening and calls to install,
config-changed, upgrade-charm and update-status hooks.
Also add new config option to allow one or more hardening
modules to be applied at runtime.

Change-Id: I525c15a14662175f2a68cdcd25a3ab2c92237850

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from mock import patch
 
1
import sys
 
2
 
 
3
from mock import patch, MagicMock
 
4
 
 
5
# python-apt is not installed as part of test-requirements but is imported by
 
6
# some charmhelpers modules so create a fake import.
 
7
sys.modules['apt'] = MagicMock()
 
8
sys.modules['apt_pkg'] = MagicMock()
2
9
 
3
10
with patch('charmhelpers.core.hookenv.config') as config:
4
11
    config.return_value = 'nova'
5
12
    import nova_compute_utils as utils  # noqa
6
13
 
7
 
with patch('nova_compute_utils.restart_map'):
8
 
    with patch('nova_compute_utils.register_configs'):
9
 
        import git_reinstall
 
14
with patch('charmhelpers.contrib.hardening.harden.harden') as mock_dec:
 
15
    mock_dec.side_effect = (lambda *dargs, **dkwargs: lambda f:
 
16
                            lambda *args, **kwargs: f(*args, **kwargs))
 
17
    with patch('nova_compute_utils.restart_map'):
 
18
        with patch('nova_compute_utils.register_configs'):
 
19
            import git_reinstall
10
20
 
11
21
from test_utils import (
12
22
    CharmTestCase