def test_domain_init_done(self):
     self.patch(designate.hookenv, 'leader_get')
     self.leader_get.return_value = True
     a = designate.DesignateCharm(release='mitaka')
     self.assertTrue(a.domain_init_done())
     self.leader_get.return_value = False
     a = designate.DesignateCharm(release='mitaka')
     self.assertFalse(a.domain_init_done())
 def test_install(self):
     self.patch(designate.DesignateCharm, 'configure_source')
     self.patch(designate.DesignateCharm, 'update_api_ports')
     self.ch_config.side_effect = lambda: {'openstack-origin': 'distro'}
     a = designate.DesignateCharm(release='mitaka')
     a.install()
     self.configure_source.assert_called_with()
 def test_write_key_file(self):
     self.patch(designate.host, 'write_file')
     a = designate.DesignateCharm(release='mitaka')
     a.write_key_file('unit1', 'keydigest')
     self.write_file.assert_called_with('/etc/designate/rndc_unit1.key',
                                        mock.ANY,
                                        owner='root',
                                        group='designate',
                                        perms=0o440)
 def test_render_rndc_keys(self):
     test_config = {
         'dns-slaves': '10.0.0.10:port1:key1 192.168.23.4:port2:key2',
     }
     self.patch(designate.DesignateCharm, 'write_key_file')
     with mock.patch.object(designate.hookenv,
                            'config',
                            side_effect=FakeConfig(test_config)):
         a = designate.DesignateCharm(release='mitaka')
         a.render_rndc_keys()
         calls = [
             mock.call('10_0_0_10', 'key1'),
             mock.call('192_168_23_4', 'key2'),
         ]
         self.write_key_file.assert_has_calls(calls)
 def test_render_base_config(self):
     self.patch(designate.DesignateCharm, 'haproxy_enabled')
     self.patch(designate.DesignateCharm, 'render_with_interfaces')
     self.patch_object(designate.DesignateCharm,
                       'haproxy_enabled',
                       new=lambda x: True)
     a = designate.DesignateCharm(release='mitaka')
     a.render_base_config('interface_list')
     expect_configs = [
         '/root/novarc', '/etc/designate/designate.conf',
         '/etc/designate/rndc.key', '/etc/default/openstack',
         '/etc/haproxy/haproxy.cfg'
     ]
     self.render_with_interfaces.assert_called_with('interface_list',
                                                    configs=expect_configs)
 def test_render_full_config(self):
     self.patch(designate.DesignateCharm, 'render_with_interfaces')
     a = designate.DesignateCharm(release='mitaka')
     a.render_full_config('interface_list')
     self.render_with_interfaces.assert_called_with('interface_list')
Example #7
0
 def test_install(self):
     self.patch(designate.DesignateCharm, 'configure_source')
     a = designate.DesignateCharm(release='mitaka')
     a.install()
     self.configure_source.assert_called_with()