Skip to content

Commit

Permalink
tests: remove test_routes.py and fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Dec 20, 2022
1 parent 8120f24 commit 79d83de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
11 changes: 0 additions & 11 deletions integration_tests/test_dir/build/index.html

This file was deleted.

17 changes: 0 additions & 17 deletions integration_tests/test_routes.py

This file was deleted.

29 changes: 20 additions & 9 deletions robyn/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,29 @@ def _format_response(self, res):
# handle file handlers
response = {}
if type(res) == dict:
if "status_code" not in res:
res["status_code"] = 200
response = res
else:
if type(res["status_code"]) == str:
res["status_code"] = int(res["status_code"])

response = {"status_code": 200, "body": res["body"], **res}
status_code = res.get("status_code", 200)
headers = res.get("headers", {})
body = res.get("body", "")

if type(status_code) != int:
status_code = int(status_code) # status_code can potentially be string

response = {
"status_code": status_code,
"body": body,
"headers": headers,
**res,
}
else:
response = {"status_code": 200, "body": res, "type": "text", "headers": {"Content-Type": "text/plain"}}
response = {
"status_code": 200,
"body": res,
"type": "text",
"headers": {"Content-Type": "text/plain"},
}

return response

def add_route(
self, route_type: str, endpoint: str, handler: Callable, is_const: bool
) -> Union[Callable, CoroutineType]:
Expand Down

0 comments on commit 79d83de

Please sign in to comment.