Skip to content
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
mock-test
  • Loading branch information
Gleekzone committed Sep 8, 2020
commit 89bf77c6b8fdc6758019bbc3ab911f8d176b2470
21 changes: 19 additions & 2 deletions tests/integrations/chalice/test_chalice.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import pytest

from chalice import Chalice
from chalice.local import LambdaContext, LocalGateway

from sentry_sdk.integrations.chalice import ChaliceIntegration

from pytest_chalice.handlers import RequestHandler


def _generate_lambda_context(self):
# Monkeypatch of the function _generate_lambda_context
# from the class LocalGateway
# for mock the timeout
# type: () -> LambdaContext
if self._config.lambda_timeout is None:
timeout = 10 * 1000
else:
timeout = self._config.lambda_timeout * 1000
return LambdaContext(
function_name=self._config.function_name,
memory_size=self._config.lambda_memory_size,
max_runtime_ms=timeout
)


@pytest.fixture
def app(sentry_init):
sentry_init(integrations=[ChaliceIntegration()])
Expand All @@ -20,10 +37,11 @@ def boom():
def has_request():
raise Exception("boom goes the dynamite!")

LocalGateway._generate_lambda_context = _generate_lambda_context

return app


@pytest.mark.skip(reason="self._max_runtime is none, the response is correct")
def test_exception_boom(app, client: RequestHandler) -> None:
response = client.get("/boom")
assert response.status_code == 500
Expand All @@ -35,7 +53,6 @@ def test_exception_boom(app, client: RequestHandler) -> None:
)


@pytest.mark.skip(reason="self._max_runtime is none, the response is correct")
def test_has_request(app, capture_events, client: RequestHandler):
events = capture_events()

Expand Down