Skip to content

Commit 90f11bc

Browse files
Merge pull request #828 from adamtheturtle/simplify-exception-tests
Consolidate exception tests
2 parents 6107e57 + cd86414 commit 90f11bc

File tree

4 files changed

+21
-76
lines changed

4 files changed

+21
-76
lines changed

tests/test_exceptions/test_image_too_large.py renamed to tests/test_exceptions.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests for giving an image which is too large.
2+
Tests for various exceptions.
33
"""
44

55
import io
@@ -10,10 +10,10 @@
1010
from requests import codes
1111

1212
from vws import VWS
13-
from vws.exceptions import ImageTooLarge
13+
from vws.exceptions import ImageTooLarge, UnknownTarget
1414

1515

16-
def make_image_file(
16+
def _make_image_file(
1717
file_format: str,
1818
color_space: str,
1919
width: int,
@@ -53,7 +53,7 @@ def test_image_too_large(client: VWS) -> None:
5353
"""
5454
width = height = 890
5555

56-
png_too_large = make_image_file(
56+
png_too_large = _make_image_file(
5757
file_format='PNG',
5858
color_space='RGB',
5959
width=width,
@@ -64,3 +64,20 @@ def test_image_too_large(client: VWS) -> None:
6464
client.add_target(name='x', width=1, image=png_too_large)
6565

6666
assert exc.value.response.status_code == codes.UNPROCESSABLE_ENTITY
67+
68+
69+
def test_invalid_given_id(client: VWS) -> None:
70+
"""
71+
Giving an invalid ID to a helper which requires a target ID to be given
72+
causes an ``UnknownTarget`` exception to be raised.
73+
"""
74+
with pytest.raises(UnknownTarget) as exc:
75+
client.delete_target(target_id='x')
76+
assert exc.value.response.status_code == codes.NOT_FOUND
77+
78+
79+
def test_request_quota_reached() -> None:
80+
"""
81+
See https://github.com/adamtheturtle/vws-python/issues/822 for writing
82+
this test.
83+
"""

tests/test_exceptions/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/test_exceptions/test_request_quota_reached.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/test_exceptions/test_unknown_target.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)