Пример #1
0
    def test_request_handler(self, mock_get):
        # event dict is {}
        response = lambda_handler.request_handler(event=self.event, context=None)
        assert (response["statusCode"] == 400)
        assert (response["body"] == '"Bad Request"')

        # event dict has invalid path
        test_event = {"path": "/dummy", "httpMethod": "GET"}
        test_event.update(self.event)
        response = lambda_handler.request_handler(event=test_event, context=None)
        assert (response["statusCode"] == 400)
        assert (response["body"] == '"Invalid URL path."')
Пример #2
0
 def test_user_signup(self):
     self.signup['requestContext'].update(self.event['requestContext'])
     response = lambda_handler.request_handler(event=self.signup, context=None)
     assert (response["statusCode"] == 200)
     response_body = json.loads(response["body"])
     assert (response_body["status"] == "success")
     # hit again with same payload
     response = lambda_handler.request_handler(event=self.signup, context=None)
     print(response)
     assert (response["statusCode"] == 500)
     response_body = json.loads(response["body"])
     assert (response_body["status"] == "failed")
 def test_signature_for_free_call(self, report_slack_mock):
     self.signature_for_free_call['requestContext'].update(
         self.event['requestContext'])
     response = lambda_handler.request_handler(
         event=self.signature_for_free_call, context=None)
     print(response)
     assert (response["statusCode"] == 200)
     response_body = json.loads(response["body"])
     assert (response_body["status"] == "success")
Пример #4
0
 def test_del_user_data(self):
     self.delete_user.update(self.event)
     response = lambda_handler.request_handler(event=self.delete_user, context=None)
     assert (response["statusCode"] == 200)
     response_body = json.loads(response["body"])
     assert (response_body["status"] == "success")