Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused function #32

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/routing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json
import logging
from datetime import datetime, timezone
from http import HTTPStatus
from typing import Any, Awaitable, Callable, Dict
from uuid import uuid4

Expand Down Expand Up @@ -63,17 +61,6 @@ async def wrapper(request: Request) -> Response:
return wrapper


def default_endpoint(request: Request) -> Response:
logger.error(f"Executing default endpoint: {request.scope}")

status_code = HTTPStatus.INTERNAL_SERVER_ERROR
media_type = "application/json"
content = json.dumps({"error": "Invalid endpoint execution"})
response = Response(status_code=status_code, media_type=media_type, content=content)

return response


def import_handler(path: str) -> Handler:
module_name, handler_name = path.rsplit(".", maxsplit=1)
module = __import__(module_name, fromlist=(handler_name,))
Expand Down
14 changes: 0 additions & 14 deletions tests/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ async def receive():


class TestAPIRoute(unittest.TestCase):
def test_default_endpoint(self):
with self.assertLogs(logger=routing.__name__, level="ERROR") as logs:
scope = {"type": "http"}
request = Request(scope)
response = routing.default_endpoint(request)

self.assertIsInstance(response, Response)
self.assertEqual(response.status_code, HTTPStatus.INTERNAL_SERVER_ERROR)
self.assertEqual(response.media_type, "application/json")
self.assertEqual(response.body, b'{"error": "Invalid endpoint execution"}')

expected_logs = ["ERROR:routing:Executing default endpoint: {'type': 'http'}"]
self.assertEqual(logs.output, expected_logs)

def test_route(self):
endpoint = "tests.fixtures.handlers.lambda_handler.handler"

Expand Down