diff --git a/requirements-test.txt b/requirements-test.txt index feb86cd..17899a4 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -4,4 +4,3 @@ black==19.10b0 isort==5.4.* flake8==3.8.* mypy==0.782 -pytest-chalice==0.0.* diff --git a/tests/test_sentry_chalice.py b/tests/test_sentry_chalice.py index 3f35218..38bbb43 100644 --- a/tests/test_sentry_chalice.py +++ b/tests/test_sentry_chalice.py @@ -1,25 +1,27 @@ -from pytest_chalice.handlers import RequestHandler +from chalice.test import Client -def test_exception_boom(app, client: RequestHandler) -> None: - response = client.get('/boom') - assert response.status_code == 500 - assert response.json == dict( - [ - ('Code', 'InternalServerError'), - ('Message', 'An internal server error occurred.'), - ] - ) +def test_exception_boom(app) -> None: + with Client(app) as client: + response = client.http.get('/boom') + assert response.status_code == 500 + assert response.json_body == dict( + [ + ('Code', 'InternalServerError'), + ('Message', 'An internal server error occurred.'), + ] + ) -def test_has_request(app, capture_events, client: RequestHandler): +def test_has_request(app, capture_events): events = capture_events() + with Client(app) as client: - response = client.get('/context') - assert response.status_code == 500 + response = client.http.get('/context') + assert response.status_code == 500 - (event,) = events - assert event["transaction"] == "api_handler" - assert "data" not in event["request"] - assert event["request"]["url"] == "awslambda:///api_handler" - assert event["request"]["headers"] == {} + (event,) = events + assert event["transaction"] == "api_handler" + assert "data" not in event["request"] + assert event["request"]["url"] == "awslambda:///api_handler" + assert event["request"]["headers"] == {}