Skip to content

Commit

Permalink
Make http_method a required HttpRequest property
Browse files Browse the repository at this point in the history
  • Loading branch information
clnoll committed Dec 6, 2022
1 parent dd7ff0c commit 9f47ef8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class HttpRequest(BaseModel):
parameters: The parameters of this HttpRequest [Optional].
body: The body of this HttpRequest [Optional].
headers: The headers of this HttpRequest [Optional].
http_method: The http_method of this HttpRequest [Optional].
http_method: The http_method of this HttpRequest.
"""

url: str
parameters: Optional[Dict[str, Any]] = None
body: Optional[Dict[str, Any]] = None
headers: Optional[Dict[str, Any]] = None
http_method: Optional[str] = None
http_method: str

HttpRequest.update_forward_refs()
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _create_request_from_log_message(self, log_message: AirbyteLogMessage) -> Op
parameters = parse_qs(url.query) or None
return HttpRequest(
url=full_path,
http_method=request.get("http_method"),
http_method=request.get("http_method", ""),
headers=request.get("headers"),
parameters=parameters,
body=request.get("body"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ components:
type: object
required:
- url
- http_method
properties:
url:
type: string
Expand All @@ -168,7 +169,7 @@ components:
description: The headers of the HTTP request, if any
http_method:
type: string
enum: ["GET", "POST", "PUT", "PATCH"]
enum: [ "GET", "POST", "PUT", "PATCH" ]
description: The http method of the request ("GET", "POST", "PUT", or "PATCH")
HttpResponse:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,24 +394,19 @@ def test_read_stream_returns_error_if_stream_does_not_exist():
id="test_create_request_with_all_fields",
),
pytest.param(
'request:{"url": "https://nichirin.com/v1/swords?color=orange", "headers": {"field": "name"}, "body":{"key": "value"}}',
'request:{"url": "https://nichirin.com/v1/swords?color=orange", "http_method": "GET", "headers": {"field": "name"}}',
HttpRequest(url="https://nichirin.com/v1/swords", parameters={"color": ["orange"]}, headers={"field": "name"},
body={"key": "value"}),
id="test_create_request_with_no_http_method",
),
pytest.param(
'request:{"url": "https://nichirin.com/v1/swords?color=orange", "headers": {"field": "name"}}',
HttpRequest(url="https://nichirin.com/v1/swords", parameters={"color": ["orange"]}, headers={"field": "name"}),
http_method="GET"),
id="test_create_request_with_no_body",
),
pytest.param(
'request:{"url": "https://nichirin.com/v1/swords?color=orange", "body":{"key": "value"}}',
HttpRequest(url="https://nichirin.com/v1/swords", parameters={"color": ["orange"]}, body={"key": "value"}),
'request:{"url": "https://nichirin.com/v1/swords?color=orange", "http_method": "PUT", "body":{"key": "value"}}',
HttpRequest(url="https://nichirin.com/v1/swords", parameters={"color": ["orange"]}, body={"key": "value"}, http_method="PUT"),
id="test_create_request_with_no_headers",
),
pytest.param(
'request:{"url": "https://nichirin.com/v1/swords", "headers": {"field": "name"}, "body":{"key": "value"}}',
HttpRequest(url="https://nichirin.com/v1/swords", headers={"field": "name"}, body={"key": "value"}),
'request:{"url": "https://nichirin.com/v1/swords", "http_method": "PUT", "headers": {"field": "name"}, "body":{"key": "value"}}',
HttpRequest(url="https://nichirin.com/v1/swords", headers={"field": "name"}, body={"key": "value"}, http_method="PUT"),
id="test_create_request_with_no_parameters",
),
pytest.param("request:{invalid_json: }", None, id="test_invalid_json_still_does_not_crash"),
Expand Down

0 comments on commit 9f47ef8

Please sign in to comment.