-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to run checks in all app and test folders
- Loading branch information
1 parent
5154b21
commit e09a07c
Showing
5 changed files
with
58 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,45 @@ | |
from uuid import uuid4 | ||
|
||
from fastapi import status | ||
from fastapi.testclient import TestClient | ||
|
||
from app.v3.notifications.rest import RESPONSE_400 | ||
from app.v3.notifications.route_schema import NotificationSingleRequest | ||
|
||
|
||
def test_get(client): | ||
def test_get(client: TestClient) -> None: | ||
"""Test GET /v3/notifications/. | ||
Args: | ||
---- | ||
client(TestClient): FastAPI client fixture | ||
""" | ||
resp = client.get(f'/v3/notifications/{uuid4()}') | ||
assert resp.status_code == status.HTTP_200_OK | ||
|
||
|
||
def test_get_missing_uuid(client): | ||
def test_get_missing_uuid(client: TestClient) -> None: | ||
"""Test GET /v3/notifications/ with a missing uuid. | ||
Args: | ||
---- | ||
client(TestClient): FastAPI client fixture | ||
""" | ||
# will think it's supposed to be a POST so throws 405 instead of 404 (FastAPI) | ||
resp = client.get('/v3/notifications/') | ||
assert resp.status_code == status.HTTP_405_METHOD_NOT_ALLOWED | ||
|
||
|
||
def test_get_malformed_request(client): | ||
def test_get_malformed_request(client: TestClient) -> None: | ||
"""Test GET /v3/notifications/ with a malformed request. | ||
Args: | ||
---- | ||
client(TestClient): FastAPI client fixture | ||
""" | ||
malformed_uuid = '1234' | ||
resp = client.get(f'/v3/notifications/{malformed_uuid}') | ||
resp_text = resp.text | ||
|
@@ -32,7 +54,14 @@ def test_get_malformed_request(client): | |
assert malformed_uuid in resp_text | ||
|
||
|
||
def test_post(client): | ||
def test_post(client: TestClient) -> None: | ||
"""Test POST /v3/notifications/. | ||
Args: | ||
---- | ||
client(TestClient): FastAPI client fixture | ||
""" | ||
srequest = NotificationSingleRequest( | ||
to='[email protected]', | ||
personalization={'hello': 'world'}, | ||
|
@@ -42,7 +71,14 @@ def test_post(client): | |
assert resp.status_code == status.HTTP_202_ACCEPTED | ||
|
||
|
||
def test_post_no_personalization(client): | ||
def test_post_no_personalization(client: TestClient) -> None: | ||
"""Test POST /v3/notifications/ with no personalization. | ||
Args: | ||
---- | ||
client(TestClient): FastAPI client fixture | ||
""" | ||
srequest = NotificationSingleRequest( | ||
to='[email protected]', | ||
template=uuid4(), | ||
|
@@ -51,8 +87,15 @@ def test_post_no_personalization(client): | |
assert resp.status_code == status.HTTP_202_ACCEPTED | ||
|
||
|
||
def test_post_malformed_request(client): | ||
request = {} | ||
def test_post_malformed_request(client: TestClient) -> None: | ||
"""Test POST /v3/notifications/ with a malformed request. | ||
Args: | ||
---- | ||
client(TestClient): FastAPI client fixture | ||
""" | ||
request: dict[str, str] = {} | ||
resp = client.post('v3/notifications', data=request) | ||
resp_text = resp.text | ||
|
||
|