Skip to content

Commit dde8ff0

Browse files
committed
Add character out of range tests to test_update_target
1 parent 0358d86 commit dde8ff0

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

tests/mock_vws/test_update_target.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,19 @@ class TestTargetName:
478478
Tests for the target name field.
479479
"""
480480

481+
_MAX_CHAR_VALUE = 65535
482+
481483
@pytest.mark.parametrize(
482484
'name',
483485
[
484-
'a',
486+
'á',
487+
# We test just below the max character value.
488+
# This is because targets with the max character value in their
489+
# names get stuck in the processing stage.
490+
chr(_MAX_CHAR_VALUE - 2),
485491
'a' * 64,
486492
],
487-
ids=['Short name', 'Long name'],
493+
ids=['Short name', 'Max char value', 'Long name'],
488494
)
489495
def test_name_valid(
490496
self,
@@ -493,7 +499,10 @@ def test_name_valid(
493499
target_id: str,
494500
) -> None:
495501
"""
496-
Names between 1 and 64 characters in length are valid.
502+
A target's name must be a string of length 0 < N < 65.
503+
504+
We test characters out of range in another test as that gives a
505+
different error.
497506
"""
498507
wait_for_target_processed(
499508
vuforia_database_keys=vuforia_database_keys,
@@ -550,6 +559,32 @@ def test_name_invalid(
550559
result_code=ResultCodes.FAIL,
551560
)
552561

562+
def test_character_out_of_range(
563+
self,
564+
png_rgb: io.BytesIO,
565+
vuforia_database_keys: VuforiaDatabaseKeys,
566+
) -> None:
567+
name = chr(self._MAX_CHAR_VALUE + 1)
568+
image_data = png_rgb.read()
569+
image_data_encoded = base64.b64encode(image_data).decode('ascii')
570+
571+
data = {
572+
'name': name,
573+
'width': 1,
574+
'image': image_data_encoded,
575+
}
576+
577+
response = add_target_to_vws(
578+
vuforia_database_keys=vuforia_database_keys,
579+
data=data,
580+
)
581+
582+
assert_vws_failure(
583+
response=response,
584+
status_code=codes.INTERNAL_SERVER_ERROR,
585+
result_code=ResultCodes.FAIL,
586+
)
587+
553588
def test_existing_target_name(
554589
self,
555590
png_rgb_success: io.BytesIO,

0 commit comments

Comments
 (0)