Skip to content

Commit 9abd6fe

Browse files
committed
Consolidate exception tests
1 parent 6107e57 commit 9abd6fe

File tree

4 files changed

+31
-76
lines changed

4 files changed

+31
-76
lines changed

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

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

55
import io
66
import random
77

88
import pytest
9+
from mock_vws import MockVWS, States
910
from PIL import Image
1011
from requests import codes
1112

1213
from vws import VWS
13-
from vws.exceptions import ImageTooLarge
14+
from vws.exceptions import (
15+
BadImage,
16+
Fail,
17+
ImageTooLarge,
18+
MetadataTooLarge,
19+
ProjectInactive,
20+
TargetNameExist,
21+
TargetStatusProcessing,
22+
UnknownTarget,
23+
)
1424

1525

16-
def make_image_file(
26+
def _make_image_file(
1727
file_format: str,
1828
color_space: str,
1929
width: int,
@@ -53,7 +63,7 @@ def test_image_too_large(client: VWS) -> None:
5363
"""
5464
width = height = 890
5565

56-
png_too_large = make_image_file(
66+
png_too_large = _make_image_file(
5767
file_format='PNG',
5868
color_space='RGB',
5969
width=width,
@@ -64,3 +74,20 @@ def test_image_too_large(client: VWS) -> None:
6474
client.add_target(name='x', width=1, image=png_too_large)
6575

6676
assert exc.value.response.status_code == codes.UNPROCESSABLE_ENTITY
77+
78+
79+
def test_invalid_given_id(client: VWS) -> None:
80+
"""
81+
Giving an invalid ID to a helper which requires a target ID to be given
82+
causes an ``UnknownTarget`` exception to be raised.
83+
"""
84+
with pytest.raises(UnknownTarget) as exc:
85+
client.delete_target(target_id='x')
86+
assert exc.value.response.status_code == codes.NOT_FOUND
87+
88+
89+
def test_request_quota_reached() -> None:
90+
"""
91+
See https://github.com/adamtheturtle/vws-python/issues/822 for writing
92+
this test.
93+
"""

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)