|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | import calendar |
| 6 | +import datetime |
6 | 7 | import time |
7 | 8 | import uuid |
8 | 9 | from http import HTTPStatus |
9 | | -from typing import TYPE_CHECKING, BinaryIO |
| 10 | +from typing import TYPE_CHECKING, BinaryIO, Literal |
10 | 11 |
|
11 | 12 | import pytest |
12 | 13 | from mock_vws import MockVWS |
13 | 14 | from mock_vws.database import CloudDatabase |
14 | 15 |
|
| 16 | +from tests.image_factory import IMAGE_CASES, ImageFactory |
15 | 17 | from vws import AsyncVWS |
16 | 18 | from vws.exceptions.custom_exceptions import ( |
17 | 19 | DatabaseIdNotSetError, |
|
29 | 31 | from vws.response import Response |
30 | 32 |
|
31 | 33 | if TYPE_CHECKING: |
32 | | - import datetime |
33 | 34 | import io |
34 | 35 |
|
35 | 36 |
|
@@ -65,14 +66,22 @@ async def __call__( |
65 | 66 |
|
66 | 67 |
|
67 | 68 | @pytest.mark.asyncio |
| 69 | +@pytest.mark.parametrize( |
| 70 | + argnames=("image_source", "image_mode"), argvalues=IMAGE_CASES |
| 71 | +) |
68 | 72 | async def test_get_target_summary_report( |
69 | 73 | *, |
70 | 74 | async_vws_client: AsyncVWS, |
71 | | - image: io.BytesIO | BinaryIO, |
| 75 | + image_factory: ImageFactory, |
| 76 | + image_source: Literal["high_quality_image", "image_file"], |
| 77 | + image_mode: Literal["r+b", "rb"], |
72 | 78 | ) -> None: |
73 | 79 | """Details of a target are returned by |
74 | 80 | ``get_target_summary_report``. |
75 | 81 | """ |
| 82 | + image: io.BytesIO | BinaryIO = image_factory.create( |
| 83 | + source=image_source, mode=image_mode |
| 84 | + ) |
76 | 85 | target_name = uuid.uuid4().hex |
77 | 86 | target_id = await async_vws_client.add_target( |
78 | 87 | name=target_name, |
@@ -105,12 +114,21 @@ async def test_get_target( |
105 | 114 |
|
106 | 115 |
|
107 | 116 | @pytest.mark.asyncio |
| 117 | +@pytest.mark.parametrize( |
| 118 | + argnames="report_period", argvalues=["current", "previous"] |
| 119 | +) |
108 | 120 | async def test_reco_counts_report( |
109 | 121 | *, |
110 | 122 | async_vws_client: AsyncVWS, |
111 | | - report_month: datetime.date, |
| 123 | + current_month: datetime.date, |
| 124 | + report_period: Literal["current", "previous"], |
112 | 125 | ) -> None: |
113 | 126 | """A report can be requested, waited for and downloaded.""" |
| 127 | + report_month = ( |
| 128 | + current_month |
| 129 | + if report_period == "current" |
| 130 | + else current_month - datetime.timedelta(days=1) |
| 131 | + ) |
114 | 132 | client = async_vws_client |
115 | 133 | report_request = await client.request_database_reco_counts_report( |
116 | 134 | year=report_month.year, |
|
0 commit comments