1
from mock import MagicMock, patch
1
from mock import MagicMock, patch, call
4
2
from test_utils import CharmTestCase
6
3
with patch('charmhelpers.core.hookenv.config') as config:
7
4
config.return_value = 'neutron'
8
5
import pg_dir_utils as utils
55
46
'hooks/{}'.format(hookname)])
57
48
def test_install_hook(self):
49
_pkgs = ['plumgrid-lxc', 'iovisor-dkms']
50
self.determine_packages.return_value = [_pkgs]
58
51
self._call_hook('install')
59
self.ensure_files.assert_called_with()
61
def test_plumgrid_edge_joined(self):
52
self.configure_sources.assert_called_with(update=True)
53
self.apt_install.assert_has_calls([
54
call(_pkgs, fatal=True,
55
options=['--force-yes',
56
'--option=Dpkg::Options::=--force-confold']),
58
self.load_iovisor.assert_called_with()
59
self.ensure_mtu.assert_called_with()
60
self.ensure_files.assert_called_with()
61
self.add_lcm_key.assert_called_with()
63
def test_config_changed_hook(self):
64
_pkgs = ['plumgrid-lxc', 'iovisor-dkms']
65
self.determine_packages.return_value = [_pkgs]
66
self._call_hook('config-changed')
67
self.stop_pg.assert_called_with()
68
self.configure_sources.assert_called_with(update=True)
69
self.apt_install.assert_has_calls([
70
call(_pkgs, fatal=True,
71
options=['--force-yes',
72
'--option=Dpkg::Options::=--force-confold']),
74
self.load_iovisor.assert_called_with()
75
self.ensure_mtu.assert_called_with()
76
self.ensure_files.assert_called_with()
77
self.add_lcm_key.assert_called_with()
78
self.CONFIGS.write_all.assert_called_with()
79
self.restart_pg.assert_called_with()
81
def test_neutron_joined(self):
62
82
self._call_hook('plumgrid-plugin-relation-joined')
83
self.ensure_mtu.assert_called_with()
63
84
self.ensure_files.assert_called_with()
85
self.add_lcm_key.assert_called_with()
64
86
self.CONFIGS.write_all.assert_called_with()
65
87
self.restart_pg.assert_called_with()
67
def test_plumgrid_joined(self):
69
'pg_virtual_ip': '192.168.100.250',
71
self._call_hook('plumgrid-relation-joined')
72
self.relation_set.assert_called_with(relation_id=None, **relation_data)
74
89
def test_stop(self):
90
_pkgs = ['plumgrid-lxc', 'iovisor-dkms']
75
91
self._call_hook('stop')
76
92
self.stop_pg.assert_called_with()
93
self.remove_iovisor.assert_called_with()
94
self.determine_packages.return_value = _pkgs