def test_app(self):
     from resource_api.insert_resource import app
     event = {Constants.event_body(): "{}"}
     handler_response = app.handler(event, None)
     self.assertEqual(handler_response[Constants.response_status_code()],
                      http.HTTPStatus.BAD_REQUEST,
                      'HTTP Status code not 400')
 def test_handler_missing_event(self):
     from resource_api.insert_resource import app
     dynamodb = self.setup_mock_database('eu-west-1', 'testing')
     handler_insert_response = app.handler(None, None)
     self.assertEqual(
         handler_insert_response[Constants.response_status_code()],
         http.HTTPStatus.BAD_REQUEST, 'HTTP Status code not 400')
     remove_mock_database(dynamodb)
 def test_app_event_invalid_json_in_body(self):
     from resource_api.insert_resource import app
     event = {
         Constants.event_http_method(): HttpConstants.http_method_post(),
         Constants.event_body(): "asdf"
     }
     handler_response = app.handler(event, None)
     self.assertEqual(handler_response[Constants.response_status_code()],
                      http.HTTPStatus.BAD_REQUEST,
                      'HTTP Status code not 400')
 def test_app_missing_env_region(self):
     del os.environ['REGION']
     from resource_api.insert_resource import app
     app.clear_dynamodb()
     _event = {
         Constants.event_http_method(): HttpConstants.http_method_post(),
         Constants.event_body(): "{}"
     }
     _handler_response = app.handler(_event, None)
     self.assertEqual(_handler_response[Constants.response_status_code()],
                      http.HTTPStatus.INTERNAL_SERVER_ERROR,
                      'HTTP Status code not 500')