Exemple #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)
     print(response)
     assert (response["statusCode"] == 500)
     assert (response["body"] == '"Invalid URL path."')
     # event with post query with invalid payload
     test_event = {
         "path":
         "/available-channels",
         "httpMethod":
         "POST",
         "body":
         '{"wrong_user_address": "0xFF2a327ed1Ca40CE93F116C5d6646b56991c0ddE", '
         '"org_id": "test-snet", "service_id": "tests"}'
     }
     test_event.update(self.event)
     response = lambda_handler.request_handler(event=test_event,
                                               context=None)
     assert (response["statusCode"] == 500)
     response_body = json.loads(response["body"])
     assert (response_body["status"] == "failed")
Exemple #2
0
 def test_api_get_curated_services(self):
     self.api_get_curated_services.update(self.event)
     response = lambda_handler.request_handler(
         event=self.api_get_curated_services, context=None)
     assert (response["statusCode"] == "200")
     response_body = json.loads(response["body"])
     assert (response_body["status"] == "success")
     assert (len(response_body["data"]) > 0)
Exemple #3
0
    def test_api_get_user_feedback(self):
        self.api_get_user_feedback.update(self.event)
        response = lambda_handler.request_handler(
            event=self.api_get_user_feedback, context=None)

        assert (response["statusCode"] == "200")
        response_body = json.loads(response["body"])
        assert (response_body["status"] == "success")
Exemple #4
0
    def test_api_expired_channel_info(self, mock_get):
        self.api_expired_channel_info.update(self.event)
        # mocked with high value for last block no to get expired channels
        mock_get.return_value = 1000000000000000000000000000000
        response = lambda_handler.request_handler(
            event=self.api_expired_channel_info, context=None)

        assert (response["statusCode"] == "200")
        response_body = json.loads(response["body"])
        assert (response_body["status"] == "success")
        assert (len(response_body["data"]) > 0)