Skip to content

Commit bfb2808

Browse files
committed
Add test which works on the real Vuforia
1 parent b15b37f commit bfb2808

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/mock_vws/test_get_target.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,67 @@ def test_success_status(
119119
assert new_tracking_rating == tracking_rating
120120

121121

122+
@pytest.mark.usefixtures("verify_mock_vuforia")
123+
class TestTargetTrackingRating:
124+
"""
125+
Tests which exercise the target tracking_rating, and check the image fixtures we
126+
use.
127+
"""
128+
129+
@staticmethod
130+
# We use almost all of the image fixtures here.
131+
# We do not use images which we expect to fail to upload (`png_too_large`, `bad_image_file`).
132+
def test_target_quality(
133+
vws_client: VWS,
134+
high_quality_image: io.BytesIO,
135+
image_file_failed_state: io.BytesIO,
136+
image_file_success_state_low_rating: io.BytesIO,
137+
corrupted_image_file: io.BytesIO,
138+
different_high_quality_image: io.BytesIO,
139+
) -> None:
140+
"""
141+
The target tracking rating is as expected.
142+
"""
143+
target_id_expected_rating_pairs = []
144+
for image_file in (
145+
high_quality_image,
146+
image_file_failed_state,
147+
image_file_success_state_low_rating,
148+
corrupted_image_file,
149+
different_high_quality_image,
150+
):
151+
target_id = vws_client.add_target(
152+
name=f"example_{uuid.uuid4().hex}",
153+
width=1,
154+
image=image_file,
155+
active_flag=True,
156+
application_metadata=None,
157+
)
158+
159+
expected_tracking_rating = {
160+
high_quality_image: 5,
161+
image_file_failed_state: 0,
162+
image_file_success_state_low_rating: 0,
163+
corrupted_image_file: -2,
164+
different_high_quality_image: 0,
165+
}[image_file]
166+
target_id_expected_rating_pairs.append(
167+
(target_id, expected_tracking_rating),
168+
)
169+
170+
for (
171+
target_id,
172+
expected_tracking_rating,
173+
) in target_id_expected_rating_pairs:
174+
vws_client.wait_for_target_processed(target_id=target_id)
175+
176+
target_details = vws_client.get_target_record(target_id=target_id)
177+
assert (
178+
target_details.target_record.tracking_rating
179+
== expected_tracking_rating
180+
)
181+
182+
122183
@pytest.mark.usefixtures("verify_mock_vuforia")
123184
class TestInactiveProject:
124185
"""

0 commit comments

Comments
 (0)