-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: separate conftest into unit and integration
- Loading branch information
1 parent
0fd136b
commit 9bd8d2d
Showing
3 changed files
with
26 additions
and
303 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,48 +1,22 @@ | ||
import os | ||
from copy import deepcopy | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from sketch_map_tool.exceptions import ( | ||
CustomFileNotFoundError, | ||
UploadLimitsExceededError, | ||
) | ||
from sketch_map_tool.exceptions import UploadLimitsExceededError | ||
|
||
|
||
@mock.patch.dict(os.environ, {"SMT-MAX-NR-SIM-UPLOADS": "2"}) | ||
def test_too_many_uploads(flask_client, sketch_map_markings_buffer_1): | ||
def test_max_nr_sim_uploades(flask_client, sketch_map_buffer): | ||
with pytest.raises(UploadLimitsExceededError): | ||
flask_client.post( | ||
"/digitize/results", | ||
data=dict( | ||
file=[ | ||
(sketch_map_markings_buffer_1, "file1.png"), | ||
(sketch_map_markings_buffer_1, "file2.png"), | ||
(sketch_map_markings_buffer_1, "file3.png"), | ||
(sketch_map_buffer, "file1.png"), | ||
(sketch_map_buffer, "file2.png"), | ||
(sketch_map_buffer, "file3.png"), | ||
], | ||
), | ||
follow_redirects=True, | ||
) | ||
|
||
|
||
@mock.patch.dict(os.environ, {"SMT-MAX-NR-SIM-UPLOADS": "2"}) | ||
def test_allowed_nr_of_uploads(flask_client, sketch_map_markings_buffer_1): | ||
# Successful run requires that a sketch map | ||
# has been generated on the instance beforehand | ||
try: | ||
flask_client.post( | ||
"/digitize/results", | ||
data=dict( | ||
file=[ | ||
(sketch_map_markings_buffer_1, "file1.png"), | ||
(deepcopy(sketch_map_markings_buffer_1), "file2.png"), | ||
], | ||
), | ||
follow_redirects=True, | ||
) | ||
# if we do not have a previous successful run this error will appear; | ||
# uuid of test image not in database, but the exception shows | ||
# that the uploads have been accepted and processed -> relevant code works | ||
except CustomFileNotFoundError: | ||
pass |