def test_create_aa_policy_error(self, mock_clc_sdk):
     under_test = ClcAntiAffinityPolicy(self.module)
     policy = {'name': 'dummyname', 'location': 'dummylocation'}
     error = CLCException('Failed')
     error.response_text = 'I am failed'
     mock_clc_sdk.v2.AntiAffinity.Create.side_effect = error
     under_test.clc = mock_clc_sdk
     ret = under_test._create_policy(policy)
     self.module.fail_json.assert_called_with(
         msg='Failed to create anti affinity policy : dummyname. I am failed'
     )
 def test_create_aa_policy_error(self, mock_clc_sdk):
     under_test = ClcAntiAffinityPolicy(self.module)
     policy = {
         'name': 'dummyname',
         'location': 'dummylocation'
     }
     error = CLCException('Failed')
     error.response_text = 'I am failed'
     mock_clc_sdk.v2.AntiAffinity.Create.side_effect = error
     under_test.clc = mock_clc_sdk
     ret = under_test._create_policy(policy)
     self.module.fail_json.assert_called_with(msg='Failed to create anti affinity policy : dummyname. I am failed')
 def test_delete_aa_policy_error(self, mock_clc_sdk):
     under_test = ClcAntiAffinityPolicy(self.module)
     error = CLCException('Failed')
     error.response_text = 'I am failed'
     policy_mock = mock.MagicMock()
     policy_mock.Delete.side_effect = error
     under_test.policy_dict['dummyname'] = policy_mock
     under_test.clc = mock_clc_sdk
     policy = {'name': 'dummyname', 'location': 'dummylocation'}
     ret = under_test._delete_policy(policy)
     self.module.fail_json.assert_called_with(
         msg='Failed to delete anti affinity policy : dummyname. I am failed'
     )
 def test_delete_aa_policy_error(self, mock_clc_sdk):
     under_test = ClcAntiAffinityPolicy(self.module)
     error = CLCException('Failed')
     error.response_text = 'I am failed'
     policy_mock = mock.MagicMock()
     policy_mock.Delete.side_effect = error
     under_test.policy_dict['dummyname'] = policy_mock
     under_test.clc = mock_clc_sdk
     policy = {
         'name': 'dummyname',
         'location': 'dummylocation'
     }
     ret = under_test._delete_policy(policy)
     self.module.fail_json.assert_called_with(msg='Failed to delete anti affinity policy : dummyname. I am failed')