def test_get_alert_policy_id_fail_duplicate_names(self, mock_set_clc_creds): test_params = {"alias": "testalias", "state": "absent"} self.module.params = test_params self.module.check_mode = False under_test = ClcAlertPolicy(self.module) under_test.policy_dict = {"12345": {"id": "12345", "name": "test1"}, "23456": {"id": "23456", "name": "test1"}} policy_id = under_test._get_alert_policy_id(self.module, "test1") self.module.fail_json.assert_called_once_with(msg="multiple alert policies were found with policy name : test1")
def test_get_alert_policy_id(self, mock_set_clc_creds): test_params = {"alias": "testalias", "state": "absent"} self.module.params = test_params self.module.check_mode = False under_test = ClcAlertPolicy(self.module) under_test.policy_dict = {"12345": {"id": "12345", "name": "test1"}, "23456": {"id": "23456", "name": "test2"}} policy_id = under_test._get_alert_policy_id(self.module, "test2") self.assertEqual(policy_id, "23456")
def test_get_alert_policy_id_fail_duplicate_names(self, mock_set_clc_creds): test_params = { 'alias': 'testalias' , 'state': 'absent' } self.module.params = test_params self.module.check_mode = False under_test = ClcAlertPolicy(self.module) under_test.policy_dict = {'12345': {'id': '12345', 'name': 'test1'}, '23456': {'id': '23456', 'name': 'test1'}} policy_id = under_test._get_alert_policy_id(self.module, 'test1') self.module.fail_json.assert_called_once_with(msg='multiple alert policies were found with policy name : test1')
def test_get_alert_policy_id(self, mock_set_clc_creds): test_params = { 'alias': 'testalias' , 'state': 'absent' } self.module.params = test_params self.module.check_mode = False under_test = ClcAlertPolicy(self.module) under_test.policy_dict = {'12345': {'id': '12345', 'name': 'test1'}, '23456': {'id': '23456', 'name': 'test2'}} policy_id = under_test._get_alert_policy_id(self.module, 'test2') self.assertEqual(policy_id, '23456')