Skip to content

Commit 7b0d7ff

Browse files
committed
Progress towards turning get target into get target record
1 parent b74bbce commit 7b0d7ff

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

src/vws/vws.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def add_target(
105105
"""
106106
Add a target to a Vuforia Web Services database.
107107
108+
See
109+
https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API#How-To-Add-a-Target.
110+
108111
Args:
109112
name: The name of the target.
110113
width: The width of the target.
@@ -137,9 +140,12 @@ def add_target(
137140

138141
return str(response.json()['target_id'])
139142

140-
def get_target(self, target_id: str) -> Dict[str, Any]:
143+
def get_target_record(self, target_id: str) -> Dict[str, Union[str, int]]:
141144
"""
142-
Get details of a given target.
145+
Get a given target's target record from the Target Management System.
146+
147+
See
148+
https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API#How-To-Add-a-Target.
143149
144150
Args:
145151
target_id: The ID of the target to get details of.
@@ -156,7 +162,7 @@ def get_target(self, target_id: str) -> Dict[str, Any]:
156162
base_vws_url=self._base_vws_url,
157163
)
158164

159-
return dict(response.json())
165+
return dict(response.json()['target_record'])
160166

161167
@timeout_decorator.timeout(seconds=60 * 5)
162168
def wait_for_target_processed(self, target_id: str) -> None:

tests/test_add_target.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def test_add_target(
3030
width=width,
3131
image=high_quality_image,
3232
)
33-
get_result = client.get_target(target_id=target_id)
34-
target_record = get_result['target_record']
33+
target_record = client.get_target_record(target_id=target_id)
3534
assert target_record['name'] == name
3635
assert target_record['width'] == width
3736
assert target_record['active_flag'] is True
@@ -91,8 +90,7 @@ def test_default(
9190
width=1,
9291
image=high_quality_image,
9392
)
94-
get_result = client.get_target(target_id=target_id)
95-
target_record = get_result['target_record']
93+
target_record = client.get_target_record(target_id=target_id)
9694
assert target_record['active_flag'] is True
9795

9896
@pytest.mark.parametrize('active_flag', [True, False])
@@ -111,7 +109,5 @@ def test_given(
111109
image=high_quality_image,
112110
active_flag=active_flag,
113111
)
114-
115-
get_result = client.get_target(target_id=target_id)
116-
target_record = get_result['target_record']
112+
target_record = client.get_target_record(target_id=target_id)
117113
assert target_record['active_flag'] is active_flag
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests for helper function for getting details of a target from a Vuforia
2+
Tests for helper function for getting a record of a target from a Vuforia
33
database.
44
"""
55

@@ -8,33 +8,26 @@
88
from vws import VWS
99

1010

11-
class TestGetTarget:
11+
class TestGetTargetRecord:
1212
"""
13-
Test for getting details of a target.
13+
Test for getting a record of a target.
1414
"""
1515

16-
def test_get_target(
16+
def test_get_target_record(
1717
self,
1818
client: VWS,
1919
high_quality_image: io.BytesIO,
2020
) -> None:
2121
"""
22-
Details of a target are returned by ``get_target``.
22+
Details of a target are returned by ``get_target_record``.
2323
"""
2424
target_id = client.add_target(
2525
name='x',
2626
width=1,
2727
image=high_quality_image,
2828
)
2929

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
30+
result = client.get_target_record(target_id=target_id)
3831

3932
expected_keys = {
4033
'target_id',
@@ -44,4 +37,4 @@ def test_get_target(
4437
'tracking_rating',
4538
'reco_rating',
4639
}
47-
assert result['target_record'].keys() == expected_keys
40+
assert result.keys() == expected_keys

0 commit comments

Comments
 (0)