def test_context_describe_stack_with_validation_error(self): # GIVEN client = _get_cf_stubbed_client_with_error( method='describe_stacks', service_error_code='ValidationError') context = _set_up_context(mock_client=client) stack_context = StackContext(context) # WHEN with self.assertRaises(HandledError): stack_context.describe_stack(stack_id=TEST_STACK_ID, optional=False)
def test_context_describe_stack_with_optional_and_validation_error(self): # GIVEN client = _get_cf_stubbed_client_with_error( method='describe_stacks', service_error_code='ValidationError') context = _set_up_context(mock_client=client) stack_context = StackContext(context) # WHEN response = stack_context.describe_stack(stack_id=TEST_STACK_ID, optional=True) # THEN self.assertIsNone(response)
def test_context_describe_stack_with_and_access_denied(self): # GIVEN client = _get_cf_stubbed_client_with_error( method='describe_stacks', service_error_code='AccessDenied') context = _set_up_context(mock_client=client) stack_context = StackContext(context) # WHEN response = stack_context.describe_stack(stack_id=TEST_STACK_ID, optional=False) # THEN self.assertEqual(response['StackStatus'], 'UNKNOWN') self.assertEqual(response['StackStatusReason'], 'Access denied.')
def test_context_describe_stack(self): # GIVEN expected_params = {'StackName': TEST_STACK_ID} expected_status = 'COMPLETED' response = self.__build_simple_describe_stack_response(stack_status=expected_status) client = _get_cf_stubbed_client( method='describe_stacks', response=response, expected_params=expected_params) context = _set_up_context(mock_client=client) stack_context = StackContext(context) # WHEN response = stack_context.describe_stack(stack_id=TEST_STACK_ID) # THEN self.assertEqual(response['StackId'], TEST_STACK_ID) self.assertEqual(response['StackName'], TEST_STACK_NAME) self.assertEqual(response['StackStatus'], expected_status)