File tree Expand file tree Collapse file tree 2 files changed +69
-1
lines changed
Expand file tree Collapse file tree 2 files changed +69
-1
lines changed Original file line number Diff line number Diff line change 55import base64
66import io
77import json
8- from typing import Union
8+ from typing import Any , Dict , Union
99from urllib .parse import urljoin
1010
1111import requests
@@ -133,3 +133,24 @@ def add_target(
133133 )
134134
135135 return str (response .json ()['target_id' ])
136+
137+ def get_target (self , target_id : str ) -> Dict [str , Any ]:
138+ """
139+ Get details of a given target.
140+
141+ Args:
142+ target_id: The ID of the target to get details of.
143+
144+ Returns:
145+ Response details of a target from Vuforia.
146+ """
147+ response = _target_api_request (
148+ server_access_key = self ._server_access_key ,
149+ server_secret_key = self ._server_secret_key ,
150+ method = 'GET' ,
151+ content = b'' ,
152+ request_path = f'/targets/{ target_id } ' ,
153+ base_vws_url = self ._base_vws_url ,
154+ )
155+
156+ return dict (response .json ())
Original file line number Diff line number Diff line change 1+ """
2+ Tests for helper function for getting details of a target from a Vuforia
3+ database.
4+ """
5+
6+ import io
7+
8+ from vws import VWS
9+
10+
11+ class TestGetTarget :
12+ """
13+ Test for getting details of a target.
14+ """
15+
16+ def test_get_target (
17+ self ,
18+ client : VWS ,
19+ high_quality_image : io .BytesIO ,
20+ ) -> None :
21+ """
22+ Details of a target are returned by ``get_target``.
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 (target_id = target_id )
31+ expected_keys = {
32+ 'result_code' ,
33+ 'transaction_id' ,
34+ 'target_record' ,
35+ 'status' ,
36+ }
37+ assert result .keys () == expected_keys
38+
39+ expected_keys = {
40+ 'target_id' ,
41+ 'active_flag' ,
42+ 'name' ,
43+ 'width' ,
44+ 'tracking_rating' ,
45+ 'reco_rating' ,
46+ }
47+ assert result ['target_record' ].keys () == expected_keys
You can’t perform that action at this time.
0 commit comments