-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more unit tests and fix existing test
- Loading branch information
1 parent
140b03b
commit f61f771
Showing
4 changed files
with
80 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
|
||
from ..app import app | ||
|
||
|
||
@pytest.fixture() | ||
def client() -> object: | ||
"""Create a test client for the app.""" | ||
return app.test_client() |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from unittest.mock import MagicMock, patch | ||
|
||
from ..utils import get_response | ||
|
||
FILE_PATH = "sandbox.api.utils" | ||
|
||
|
||
@patch(f"{FILE_PATH}.open") | ||
def test_get_response(mock_open: MagicMock) -> None: | ||
# Arrange | ||
mock_open.return_value.__enter__.return_value.read.return_value = ( | ||
'{"data": "mocked"}' | ||
) | ||
file_name = "./api/responses/GET_RelatedPerson/identifier.json" | ||
# Act | ||
response = get_response(file_name) | ||
# Assert | ||
mock_open.assert_called_once_with(file_name, "r") | ||
assert response == {"data": "mocked"} |