Skip to content

Commit df902c2

Browse files
committed
Merge branch 'consolidate-tests-2' into client
2 parents 94246d7 + 28e5e30 commit df902c2

File tree

5 files changed

+124
-150
lines changed

5 files changed

+124
-150
lines changed

tests/test_get_database_summary_report.py

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

tests/test_get_target_record.py

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

tests/test_get_target_summary_report.py

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def test_custom_base_url(self, high_quality_image: io.BytesIO) -> None:
111111
image=high_quality_image,
112112
)
113113

114+
114115
class TestListTargets:
115116
"""
116117
Tests for listing targets.
@@ -128,6 +129,7 @@ def test_list_targets(
128129
id_2 = client.add_target(name='a', width=1, image=high_quality_image)
129130
assert sorted(client.list_targets()) == sorted([id_1, id_2])
130131

132+
131133
class TestDelete:
132134
"""
133135
Test for deleting a target.
@@ -151,3 +153,125 @@ def test_delete_target(
151153
client.delete_target(target_id=target_id)
152154
with pytest.raises(UnknownTarget):
153155
client.get_target_record(target_id=target_id)
156+
157+
158+
class TestGetTargetSummaryReport:
159+
"""
160+
Tests for getting a summary report for a target.
161+
"""
162+
163+
def test_get_target_summary_report(
164+
self,
165+
client: VWS,
166+
high_quality_image: io.BytesIO,
167+
) -> None:
168+
"""
169+
Details of a target are returned by ``get_target_summary_report``.
170+
"""
171+
target_id = client.add_target(
172+
name='x',
173+
width=1,
174+
image=high_quality_image,
175+
)
176+
177+
result = client.get_target_summary_report(target_id=target_id)
178+
expected_keys = {
179+
'status',
180+
'result_code',
181+
'transaction_id',
182+
'database_name',
183+
'target_name',
184+
'upload_date',
185+
'active_flag',
186+
'tracking_rating',
187+
'total_recos',
188+
'current_month_recos',
189+
'previous_month_recos',
190+
}
191+
assert result.keys() == expected_keys
192+
193+
194+
class TestGetDatabaseSummaryReport:
195+
"""
196+
Tests for getting a summary report for a database.
197+
"""
198+
199+
def test_get_target(self, client: VWS) -> None:
200+
"""
201+
Details of a database are returned by ``get_database_summary_report``.
202+
"""
203+
report = client.get_database_summary_report()
204+
expected_keys = {
205+
'active_images',
206+
'current_month_recos',
207+
'failed_images',
208+
'inactive_images',
209+
'name',
210+
'previous_month_recos',
211+
'processing_images',
212+
'reco_threshold',
213+
'request_quota',
214+
'request_usage',
215+
'result_code',
216+
'target_quota',
217+
'total_recos',
218+
'transaction_id',
219+
}
220+
assert report.keys() == expected_keys
221+
222+
223+
class TestGetTargetRecord:
224+
"""
225+
Tests for getting a record of a target.
226+
"""
227+
228+
def test_get_target_record(
229+
self,
230+
client: VWS,
231+
high_quality_image: io.BytesIO,
232+
) -> None:
233+
"""
234+
Details of a target are returned by ``get_target_record``.
235+
"""
236+
target_id = client.add_target(
237+
name='x',
238+
width=1,
239+
image=high_quality_image,
240+
)
241+
242+
result = client.get_target_record(target_id=target_id)
243+
244+
expected_keys = {
245+
'target_id',
246+
'active_flag',
247+
'name',
248+
'width',
249+
'tracking_rating',
250+
'reco_rating',
251+
}
252+
assert result.keys() == expected_keys
253+
254+
255+
class TestWaitForTargetProcessed:
256+
"""
257+
Tests for waiting for a target to be processed.
258+
"""
259+
260+
def test_wait_for_target_processed(
261+
self,
262+
client: VWS,
263+
high_quality_image: io.BytesIO,
264+
) -> None:
265+
"""
266+
It is possible to wait until a target is processed.
267+
"""
268+
target_id = client.add_target(
269+
name='x',
270+
width=1,
271+
image=high_quality_image,
272+
)
273+
report = client.get_target_summary_report(target_id=target_id)
274+
assert report['status'] == 'processing'
275+
client.wait_for_target_processed(target_id=target_id)
276+
report = client.get_target_summary_report(target_id=target_id)
277+
assert report['status'] != 'processing'

tests/test_wait_for_target_processed.py

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

0 commit comments

Comments
 (0)