def test_is_db_initisalised_true(self, mock_related_units, mock_relation_ids, mock_relation_get): settings = { '0': { cinder_utils.CINDER_DB_INIT_RKEY: '1234' }, '1': { cinder_utils.CINDER_DB_INIT_ECHO_RKEY: '1234' } } def mock_rel_get(unit=None, rid=None, attribute=None): if not unit: unit = '0' if attribute: return settings[unit].get(attribute) return settings[unit] cinder_utils.local_unit.return_value = '0' mock_relation_get.side_effect = mock_rel_get mock_related_units.return_value = ['1'] mock_relation_ids.return_value = ['cluster:1'] self.assertTrue(cinder_utils.is_db_initialised())
def test_is_db_initisalised_false(self, mock_related_units, mock_relation_ids, mock_relation_get): settings = {'0': {}, '1': {}} def mock_rel_get(unit=None, rid=None, attribute=None): if not unit: unit = '0' if attribute: return settings[unit].get(attribute) return settings[unit] cinder_utils.local_unit.return_value = '0' mock_relation_get.side_effect = mock_rel_get mock_related_units.return_value = ['1'] mock_relation_ids.return_value = ['cluster:1'] self.assertFalse(cinder_utils.is_db_initialised())