1
from mock import MagicMock, patch
4
from test_utils import CharmTestCase
6
with patch('charmhelpers.core.hookenv.config') as config:
7
config.return_value = 'neutron'
8
import pg_edge_utils as utils
10
_reg = utils.register_configs
11
_map = utils.restart_map
13
utils.register_configs = MagicMock()
14
utils.restart_map = MagicMock()
16
import pg_edge_hooks as hooks
18
utils.register_configs = _reg
19
utils.restart_map = _map
27
#'determine_packages',
28
#'determine_dvr_packages',
40
NEUTRON_CONF_DIR = "/etc/neutron"
42
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
45
class PGEdgeHooksTests(CharmTestCase):
48
super(PGEdgeHooksTests, self).setUp(hooks, TO_PATCH)
50
#self.config.side_effect = self.test_config.get
51
hooks.hooks._config_save = False
53
def _call_hook(self, hookname):
55
'hooks/{}'.format(hookname)])
57
def test_install_hook(self):
58
self._call_hook('install')
59
self.ensure_files.assert_called_with()
61
def test_plumgrid_edge_joined(self):
62
self._call_hook('plumgrid-plugin-relation-joined')
63
self.ensure_files.assert_called_with()
64
self.CONFIGS.write_all.assert_called_with()
65
self.restart_pg.assert_called_with()
68
self._call_hook('stop')
69
self.stop_pg.assert_called_with()