Skip to content

Commit 70cfa1f

Browse files
Merge pull request #801 from adamtheturtle/target-summary
Add initial function to get summary report
2 parents b74bbce + 42e4d80 commit 70cfa1f

File tree

5 files changed

+72
-4
lines changed

5 files changed

+72
-4
lines changed

src/vws/vws.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def wait_for_target_processed(self, target_id: str) -> None:
183183

184184
def list_targets(self) -> List[str]:
185185
"""
186-
Get a list of targets.
186+
List target IDs.
187187
188188
Returns:
189189
The IDs of all targets in the database.
@@ -198,3 +198,27 @@ def list_targets(self) -> List[str]:
198198
)
199199

200200
return list(response.json()['results'])
201+
202+
def get_target_summary_report(
203+
self,
204+
target_id: str,
205+
) -> Dict[str, Union[str, int]]:
206+
"""
207+
Get a summary report for a target.
208+
209+
Args:
210+
target_id: The ID of the target to get a summary report for.
211+
212+
Returns:
213+
Details of the target.
214+
"""
215+
response = _target_api_request(
216+
server_access_key=self._server_access_key,
217+
server_secret_key=self._server_secret_key,
218+
method='GET',
219+
content=b'',
220+
request_path=f'/summary/{target_id}',
221+
base_vws_url=self._base_vws_url,
222+
)
223+
224+
return dict(response.json())

tests/test_get_target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class TestGetTarget:
1212
"""
13-
Test for getting details of a target.
13+
Tests for getting details of a target.
1414
"""
1515

1616
def test_get_target(
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
Tests for helper function for getting a summary report for a target in a
3+
Vuforia database.
4+
"""
5+
6+
import io
7+
8+
from vws import VWS
9+
10+
11+
class TestGetTargetSummaryReport:
12+
"""
13+
Tests for getting a summary report for a target.
14+
"""
15+
16+
def test_get_target_summary_report(
17+
self,
18+
client: VWS,
19+
high_quality_image: io.BytesIO,
20+
) -> None:
21+
"""
22+
Details of a target are returned by ``get_target_summary_report``.
23+
"""
24+
target_id = client.add_target(
25+
name='x',
26+
width=1,
27+
image=high_quality_image,
28+
)
29+
30+
result = client.get_target_summary_report(target_id=target_id)
31+
expected_keys = {
32+
'status',
33+
'result_code',
34+
'transaction_id',
35+
'database_name',
36+
'target_name',
37+
'upload_date',
38+
'active_flag',
39+
'tracking_rating',
40+
'total_recos',
41+
'current_month_recos',
42+
'previous_month_recos',
43+
}
44+
assert result.keys() == expected_keys

tests/test_target_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class TestListTargets:
1111
"""
12-
Test for listing targets.
12+
Tests for listing targets.
1313
"""
1414

1515
def test_list_targets(

tests/test_wait_for_target_processed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class TestWaitForTargetProcessed:
1111
"""
12-
Test for waiting for a target to be processed.
12+
Tests for waiting for a target to be processed.
1313
"""
1414

1515
def test_wait_for_target_processed(

0 commit comments

Comments
 (0)