Skip to content

Commit

Permalink
add-client-test (#10)
Browse files Browse the repository at this point in the history
* add-client-test

* remove-pytest-chalice

* bump-version

* old-version
  • Loading branch information
Gleekzone authored Aug 17, 2020
1 parent 1df8989 commit fd45fda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
1 change: 0 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ black==19.10b0
isort==5.4.*
flake8==3.8.*
mypy==0.782
pytest-chalice==0.0.*
38 changes: 20 additions & 18 deletions tests/test_sentry_chalice.py
Original file line number Diff line number Diff line change
@@ -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"] == {}

0 comments on commit fd45fda

Please sign in to comment.