Skip to content

Commit 46e4317

Browse files
committed
Update more tests to handle new response for corrupted images
1 parent 7db3d82 commit 46e4317

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

tests/mock_vws/test_flask_app_usage.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class TestTargetRaters:
455455

456456
@staticmethod
457457
def test_default(
458-
corrupted_image_file: io.BytesIO,
458+
image_file_success_state_low_rating: io.BytesIO,
459459
high_quality_image: io.BytesIO,
460460
) -> None:
461461
"""
@@ -470,10 +470,10 @@ def test_default(
470470
server_secret_key=database.server_secret_key,
471471
)
472472

473-
corrupted_image_target_id = vws_client.add_target(
473+
low_rating_image_target_id = vws_client.add_target(
474474
name=uuid.uuid4().hex,
475475
width=1,
476-
image=corrupted_image_file,
476+
image=image_file_success_state_low_rating,
477477
application_metadata=None,
478478
active_flag=True,
479479
)
@@ -487,27 +487,26 @@ def test_default(
487487
)
488488

489489
for target_id in (
490-
corrupted_image_target_id,
490+
low_rating_image_target_id,
491491
high_quality_image_target_id,
492492
):
493493
vws_client.wait_for_target_processed(target_id=target_id)
494494

495-
corrupted_image_rating = vws_client.get_target_record(
496-
target_id=corrupted_image_target_id,
495+
low_rated_image_rating = vws_client.get_target_record(
496+
target_id=low_rating_image_target_id,
497497
).target_record.tracking_rating
498498

499499
high_quality_image_rating = vws_client.get_target_record(
500500
target_id=high_quality_image_target_id,
501501
).target_record.tracking_rating
502502

503-
# In the real Vuforia, this image may rate as -2.
504-
assert corrupted_image_rating <= 0
503+
assert low_rated_image_rating <= 0
505504
assert high_quality_image_rating > 1
506505

507506
@staticmethod
508507
def test_brisque(
509508
monkeypatch: pytest.MonkeyPatch,
510-
corrupted_image_file: io.BytesIO,
509+
image_file_success_state_low_rating: io.BytesIO,
511510
high_quality_image: io.BytesIO,
512511
) -> None:
513512
"""
@@ -524,10 +523,10 @@ def test_brisque(
524523
server_secret_key=database.server_secret_key,
525524
)
526525

527-
corrupted_image_target_id = vws_client.add_target(
526+
low_rating_image_target_id = vws_client.add_target(
528527
name=uuid.uuid4().hex,
529528
width=1,
530-
image=corrupted_image_file,
529+
image=image_file_success_state_low_rating,
531530
application_metadata=None,
532531
active_flag=True,
533532
)
@@ -541,21 +540,20 @@ def test_brisque(
541540
)
542541

543542
for target_id in (
544-
corrupted_image_target_id,
543+
low_rating_image_target_id,
545544
high_quality_image_target_id,
546545
):
547546
vws_client.wait_for_target_processed(target_id=target_id)
548547

549-
corrupted_image_rating = vws_client.get_target_record(
550-
target_id=corrupted_image_target_id,
548+
low_rated_image_rating = vws_client.get_target_record(
549+
target_id=low_rating_image_target_id,
551550
).target_record.tracking_rating
552551

553552
high_quality_image_rating = vws_client.get_target_record(
554553
target_id=high_quality_image_target_id,
555554
).target_record.tracking_rating
556555

557-
# In the real Vuforia, this image may rate as -2.
558-
assert corrupted_image_rating <= 0
556+
assert low_rated_image_rating <= 0
559557
assert high_quality_image_rating > 1
560558

561559
@staticmethod

tests/mock_vws/test_target_raters.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ class TestBrisqueTargetTrackingRater:
5050
"""
5151

5252
@staticmethod
53-
def test_low_quality_image(corrupted_image_file: io.BytesIO) -> None:
53+
def test_low_quality_image(
54+
image_file_success_state_low_rating: io.BytesIO,
55+
) -> None:
5456
"""
5557
Test that a low quality image returns a low rating.
5658
"""
5759
rater = BrisqueTargetTrackingRater()
58-
image_content = corrupted_image_file.getvalue()
60+
image_content = image_file_success_state_low_rating.getvalue()
5961
rating = rater(image_content=image_content)
60-
# In the real Vuforia, this image may rate as -2.
6162
assert rating == 0
6263

6364
@staticmethod

0 commit comments

Comments
 (0)