Rename _relations.py -> _hooks.py
This commit is contained in:
@@ -7,7 +7,7 @@ import hooks.swift_storage_utils as utils
|
||||
_reg = utils.register_configs
|
||||
utils.register_configs = MagicMock()
|
||||
|
||||
import hooks.swift_storage_relations as relations
|
||||
import hooks.swift_storage_hooks as hooks
|
||||
|
||||
utils.register_configs = _reg
|
||||
|
||||
@@ -40,14 +40,14 @@ TO_PATCH = [
|
||||
|
||||
class SwiftStorageRelationsTests(CharmTestCase):
|
||||
def setUp(self):
|
||||
super(SwiftStorageRelationsTests, self).setUp(relations,
|
||||
super(SwiftStorageRelationsTests, self).setUp(hooks,
|
||||
TO_PATCH)
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.relation_get.side_effect = self.test_relation.get
|
||||
|
||||
def test_install_hook(self):
|
||||
self.test_config.set('openstack-origin', 'cloud:precise-havana')
|
||||
relations.install()
|
||||
hooks.install()
|
||||
self.configure_installation_source.assert_called_with(
|
||||
'cloud:precise-havana',
|
||||
)
|
||||
@@ -58,19 +58,19 @@ class SwiftStorageRelationsTests(CharmTestCase):
|
||||
|
||||
def test_config_changed_no_upgrade_available(self):
|
||||
self.openstack_upgrade_available.return_value = False
|
||||
relations.config_changed()
|
||||
hooks.config_changed()
|
||||
self.assertFalse(self.do_openstack_upgrade.called)
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
|
||||
def test_config_changed_upgrade_available(self):
|
||||
self.openstack_upgrade_available.return_value = True
|
||||
relations.config_changed()
|
||||
hooks.config_changed()
|
||||
self.assertTrue(self.do_openstack_upgrade.called)
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
|
||||
def test_storage_joined_single_device(self):
|
||||
self.determine_block_devices.return_value = ['/dev/vdb']
|
||||
relations.swift_storage_relation_joined()
|
||||
hooks.swift_storage_relation_joined()
|
||||
self.relation_set.assert_called_with(
|
||||
device='vdb', object_port=6000, account_port=6002,
|
||||
zone=1, container_port=6001
|
||||
@@ -79,7 +79,7 @@ class SwiftStorageRelationsTests(CharmTestCase):
|
||||
def test_storage_joined_multi_device(self):
|
||||
self.determine_block_devices.return_value = ['/dev/vdb', '/dev/vdc',
|
||||
'/dev/vdd']
|
||||
relations.swift_storage_relation_joined()
|
||||
hooks.swift_storage_relation_joined()
|
||||
self.relation_set.assert_called_with(
|
||||
device='vdb:vdc:vdd', object_port=6000, account_port=6002,
|
||||
zone=1, container_port=6001
|
||||
@@ -87,7 +87,7 @@ class SwiftStorageRelationsTests(CharmTestCase):
|
||||
|
||||
@patch('sys.exit')
|
||||
def test_storage_changed_missing_relation_data(self, exit):
|
||||
relations.swift_storage_relation_changed()
|
||||
hooks.swift_storage_relation_changed()
|
||||
exit.assert_called_with(0)
|
||||
|
||||
def test_storage_changed_with_relation_data(self):
|
||||
@@ -95,21 +95,21 @@ class SwiftStorageRelationsTests(CharmTestCase):
|
||||
'swift_hash': 'foo_hash',
|
||||
'rings_url': 'http://swift-proxy.com/rings/',
|
||||
})
|
||||
relations.swift_storage_relation_changed()
|
||||
hooks.swift_storage_relation_changed()
|
||||
self.CONFIGS.write.assert_called_with('/etc/swift/swift.conf')
|
||||
self.fetch_swift_rings.assert_called_with(
|
||||
'http://swift-proxy.com/rings/'
|
||||
)
|
||||
|
||||
@patch('sys.argv')
|
||||
@patch.object(relations, 'install')
|
||||
@patch.object(hooks, 'install')
|
||||
def test_main_hook_exists(self, _install, _argv):
|
||||
_argv = ['hooks/install']
|
||||
relations.main()
|
||||
hooks.main()
|
||||
_install.assert_called()
|
||||
|
||||
@patch('sys.argv')
|
||||
def test_main_hook_missing(self, _argv):
|
||||
_argv = ['hooks/start']
|
||||
relations.main()
|
||||
hooks.main()
|
||||
self.log.assert_called()
|
||||
|
||||
Reference in New Issue
Block a user