Skip to content

Commit 4b52fca

Browse files
committed
Move a few tests into test_exceptions
1 parent 90f11bc commit 4b52fca

File tree

3 files changed

+47
-43
lines changed

3 files changed

+47
-43
lines changed

tests/test_add_target.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from requests import codes
1010

1111
from vws import VWS
12-
from vws.exceptions import MetadataTooLarge, TargetNameExist
12+
from vws.exceptions import TargetNameExist
1313

1414

1515
class TestSuccess:
@@ -129,25 +129,6 @@ def test_given(
129129
application_metadata=b'a',
130130
)
131131

132-
def test_too_large(
133-
self,
134-
client: VWS,
135-
high_quality_image: io.BytesIO,
136-
) -> None:
137-
"""
138-
A ``MetadataTooLarge`` exception is raised if the metadata given is too
139-
large.
140-
"""
141-
with pytest.raises(MetadataTooLarge) as exc:
142-
client.add_target(
143-
name='x',
144-
width=1,
145-
image=high_quality_image,
146-
application_metadata=b'a' * 1024 * 1024,
147-
)
148-
149-
assert exc.value.response.status_code == codes.UNPROCESSABLE_ENTITY
150-
151132

152133
class TestActiveFlag:
153134
"""

tests/test_delete_target.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,16 @@
55
import io
66

77
import pytest
8-
from requests import codes
98

109
from vws import VWS
11-
from vws.exceptions import TargetStatusProcessing, UnknownTarget
10+
from vws.exceptions import UnknownTarget
1211

1312

1413
class TestDelete:
1514
"""
1615
Test for deleting a target.
1716
"""
1817

19-
def test_target_processing(
20-
self,
21-
client: VWS,
22-
high_quality_image: io.BytesIO,
23-
) -> None:
24-
"""
25-
A ``TargetStatusProcessing`` exception is raised if trying to delete a
26-
target which is processing.
27-
"""
28-
target_id = client.add_target(
29-
name='x',
30-
width=1,
31-
image=high_quality_image,
32-
)
33-
34-
with pytest.raises(TargetStatusProcessing) as exc:
35-
client.delete_target(target_id=target_id)
36-
37-
assert exc.value.response.status_code == codes.FORBIDDEN
38-
3918
def test_delete_target(
4019
self,
4120
client: VWS,

tests/test_exceptions.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
from requests import codes
1111

1212
from vws import VWS
13-
from vws.exceptions import ImageTooLarge, UnknownTarget
13+
from vws.exceptions import (
14+
ImageTooLarge,
15+
MetadataTooLarge,
16+
TargetStatusProcessing,
17+
UnknownTarget,
18+
)
1419

1520

1621
def _make_image_file(
@@ -81,3 +86,42 @@ def test_request_quota_reached() -> None:
8186
See https://github.com/adamtheturtle/vws-python/issues/822 for writing
8287
this test.
8388
"""
89+
90+
91+
def test_target_status_processing(
92+
client: VWS,
93+
high_quality_image: io.BytesIO,
94+
) -> None:
95+
"""
96+
A ``TargetStatusProcessing`` exception is raised if trying to delete a
97+
target which is processing.
98+
"""
99+
target_id = client.add_target(
100+
name='x',
101+
width=1,
102+
image=high_quality_image,
103+
)
104+
105+
with pytest.raises(TargetStatusProcessing) as exc:
106+
client.delete_target(target_id=target_id)
107+
108+
assert exc.value.response.status_code == codes.FORBIDDEN
109+
110+
111+
def test_metadata_too_large(
112+
client: VWS,
113+
high_quality_image: io.BytesIO,
114+
) -> None:
115+
"""
116+
A ``MetadataTooLarge`` exception is raised if the metadata given is too
117+
large.
118+
"""
119+
with pytest.raises(MetadataTooLarge) as exc:
120+
client.add_target(
121+
name='x',
122+
width=1,
123+
image=high_quality_image,
124+
application_metadata=b'a' * 1024 * 1024,
125+
)
126+
127+
assert exc.value.response.status_code == codes.UNPROCESSABLE_ENTITY

0 commit comments

Comments
 (0)