-
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.
Kjører en simpel mock test
- Loading branch information
victbakk
committed
Feb 22, 2024
1 parent
a7bb137
commit 1cea81f
Showing
12 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"Config": {"data_parameters": ["90", "10", "100"], "layers": ["Bygning", "Veg", "Bru"], "colors": ["#000000", "#ffff00", "#00ff00"]}} | ||
{"Config": {"data_parameters": [0.4, 0.4, 0.4], "layers": ["Bygning"], "colors": ["#000000"]}} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"Coordinates": [[593258.009753139, 6644808.377803862], [593255.0498549859, 6644925.788442824], [593641.2676597863, 6644935.545142756], [593644.2398199342, 6644818.134709595], [593258.009753139, 6644808.377803862]]} | ||
{"Coordinates": [592779.1140089021, 6647491.588284892, 592763.7375065162, 6648104.070222126, 593262.1290835012, 6648116.616443546, 593277.5882226683, 6647504.13588983, 592779.1140089021, 6647491.588284892]} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from fastapi.testclient import TestClient | ||
from main import app | ||
from unittest.mock import patch | ||
from unittest.mock import patch, MagicMock | ||
|
||
|
||
#Import test client | ||
|
@@ -47,3 +47,32 @@ def test_generatePhotos(): | |
|
||
def cleanup_test_data(): | ||
pass | ||
|
||
@patch('main.send_email_with_attachment') | ||
@patch('main.zip_files') | ||
@patch('os.remove') | ||
@patch('main.util.teardown_WMS_folders') | ||
def test_send_zipped_files_email(mock_teardown, mock_remove, mock_zip, mock_send_email): | ||
# Mock the behavior of external dependencies | ||
mock_zip.return_value = None | ||
mock_send_email.return_value = None | ||
mock_remove.return_value = None | ||
mock_teardown.return_value = None | ||
|
||
# Simulate a request with a JSON payload containing the email | ||
response = client.post("/sendEmail", json={"email": "[email protected]"}) | ||
|
||
# Assertions to verify the endpoint behavior | ||
assert response.status_code == 200 | ||
assert response.json() == {"message": "Email sent successfully with zipped files."} | ||
|
||
# Verify that the mocked functions were called as expected | ||
mock_zip.assert_called_once_with() # Add any arguments if your function requires them | ||
mock_send_email.assert_called_once_with( | ||
to_emails="[email protected]", | ||
subject="Here are your zipped files", | ||
content="<strong>Zip file holding the requested data.</strong>", | ||
attachment_path="attachments.zip" | ||
) | ||
mock_remove.assert_called_once_with("attachments.zip") | ||
mock_teardown.assert_called_once() |