def test_context_get_stack_status_client_failure(self): # GIVEN client = _get_cf_stubbed_client_with_error( method='describe_stacks', service_error_code="ClientError", service_message="Stack with id {TEST_STACK_ID} does not exist") context = _set_up_context(mock_client=client) stack_context = StackContext(context) # WHEN with self.assertRaises(botocore.exceptions.ClientError): stack_context.get_stack_status(stack_id=TEST_STACK_ID)
def test_context_get_stack_status_validation_failure(self): # GIVEN client = _get_cf_stubbed_client_with_error( method='describe_stacks', service_error_code="ValidationError", service_message=f"Stack with id {TEST_STACK_ID} does not exist") context = _set_up_context(mock_client=client) stack_context = StackContext(context) # WHEN status = stack_context.get_stack_status(stack_id=TEST_STACK_ID) # THEN self.assertIsNone(status)
def test_context_get_stack_status(self): # GIVEN expected_status = 'COMPLETED' expected_params = {'StackName': TEST_STACK_ID} 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 status = stack_context.get_stack_status(stack_id=TEST_STACK_ID) # THEN self.assertEqual(status, expected_status)