def test_soochis_with_group(self, get_yaml): get_yaml.side_effect = self.mock_get_yaml soochis = input_file.get_soochis(soochis=[], groups=['deployment']) for _, soochi in soochis: self.assertIn(soochi, [base.get_test_keystone_soochi(), base.get_test_glance_soochi()])
def test_get_soochis_both(self, get_yaml): get_yaml.side_effect = self.mock_get_yaml soochis = input_file.get_soochis( soochis=['test_glance', 'test_keystone'], groups=[]) exp_output = [base.get_test_keystone_soochi(), base.get_test_glance_soochi()] expected_output = self.match_soochi_format(exp_output) for exp in expected_output: self.assertIn(exp, soochis)
def test_with_invalid_groups(self, get_yaml): def get_yaml_file(location): if 'main' in location: t_soochis = base.get_main_yaml() t_soochis['monitor']['groups'] = ['test_group'] return t_soochis return self.mock_get_yaml(location) get_yaml.side_effect = get_yaml_file soochis = input_file.get_soochis(soochis=[], groups=['monitor']) self.assertEqual([], soochis)
def test_soochis_two_group(self, get_yaml): get_yaml.side_effect = self.mock_get_yaml soochis = input_file.get_soochis(soochis=[], groups=['monitor', 'deployment']) exp_soochis = [base.get_test_keystone_soochi(), base.get_test_glance_soochi()] for _, soochi in soochis: self.assertIn(soochi, exp_soochis) self.assertEqual(len(soochis), len(exp_soochis)) self.assertEqual(get_yaml.call_count, 3)
def test_soochis_with_no_input(self, get_yaml): def get_yaml_file(location): if 'main' in location: t_soochis = base.get_main_yaml() del t_soochis['monitor']['soochis']['test_keystone'] del t_soochis['monitor']['groups'] return t_soochis return self.mock_get_yaml(location) get_yaml.side_effect = get_yaml_file soochis = input_file.get_soochis(soochis=[], groups=['monitor']) exp_soochis = self.match_soochi_format([base.get_test_glance_soochi()]) self.assertEqual(soochis, exp_soochis)
def test_soochis_invalid_jaanch(self, get_yaml): get_yaml.side_effect = self.mock_get_yaml soochis = input_file.get_soochis(soochis=[], groups=['monitor', 'deployment']) exp_soochis = [base.get_test_keystone_soochi()] tmp = base.get_test_glance_soochi() del tmp['jaanches']['port_9292'] exp_soochis.append(tmp) for _, soochi in soochis: if soochi['jaanches'].get('port_9292'): del soochi['jaanches']['port_9292'] self.assertIn(soochi, exp_soochis)
def test_with_invalid_soochi(self, get_yaml): def get_yaml_file(location): if 'main' in location: t_soochis = base.get_main_yaml() t_soochis['monitor']['soochis']['test_soochi'] = { 'soochi': 'test_soochi'} return t_soochis return self.mock_get_yaml(location) get_yaml.side_effect = get_yaml_file soochis = input_file.get_soochis(soochis=[], groups=['monitor']) exp_soochis = [base.get_test_keystone_soochi(), base.get_test_glance_soochi()] for soochi in exp_soochis: self.assertIn(({}, soochi), soochis)
def test_with_all_soochi_groups(self, get_yaml): def get_yaml_file(location): if 'main' in location: t_soochis = base.get_main_yaml() del t_soochis['monitor']['soochis']['test_keystone'] del t_soochis['deployment']['soochis']['test_glance'] return t_soochis return self.mock_get_yaml(location) get_yaml.side_effect = get_yaml_file soochis = input_file.get_soochis(soochis=[], groups=['monitor']) exp_soochis = [base.get_test_keystone_soochi(), base.get_test_glance_soochi()] expected_output = self.match_soochi_format(exp_soochis) for soochi in expected_output: self.assertIn(soochi, soochis)
def test_soochis_soochi_group(self, get_yaml): def get_yaml_file(location): if 'main' in location: t_soochis = base.get_main_yaml() del t_soochis['monitor']['soochis']['test_keystone'] del t_soochis['monitor']['groups'] return t_soochis return self.mock_get_yaml(location) get_yaml.side_effect = get_yaml_file soochis = input_file.get_soochis(soochis=['test_keystone'], groups=['monitor']) exp_soochis = [base.get_test_keystone_soochi(), base.get_test_glance_soochi()] for _, soochi in soochis: self.assertIn(soochi, exp_soochis) self.assertEqual(len(soochis), len(exp_soochis))
def test_get_soochis_glance(self, get_yaml): get_yaml.side_effect = self.mock_get_yaml soochis = input_file.get_soochis(soochis=['test_glance'], groups=[]) exp_output = [base.get_test_glance_soochi()] expected_output = self.match_soochi_format(exp_output) self.assertEqual(soochis, expected_output)
def test_with_no_soochi_groups_(self, get_yaml): soochis = input_file.get_soochis(soochis=[], groups=['monitor']) get_yaml.assert_called_once() self.assertEqual(soochis, [])
def _get_soochis(soochis=None, groups=None): """Calls the input module to return soochis to be executed""" return inputs.get_soochis(soochis, groups)