Skip to content

Commit 3b189e2

Browse files
committed
Passing test on real
1 parent 970c617 commit 3b189e2

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

tests/mock_vws/test_add_target.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -645,18 +645,25 @@ class TestApplicationMetadata:
645645
Tests for the application metadata parameter.
646646
"""
647647

648+
@pytest.mark.parametrize(
649+
'metadata',
650+
[
651+
b'a',
652+
# This is the maximum metadata length.
653+
b'a' * (1024 * 1024),
654+
],
655+
)
648656
def test_base64_encoded(
649657
self,
650658
vuforia_database_keys: VuforiaDatabaseKeys,
651659
png_rgb: io.BytesIO,
660+
metadata: bytes,
652661
) -> None:
653662
"""
654663
A base64 encoded string is valid application metadata.
655664
"""
656665
image_data = png_rgb.read()
657666
image_data_encoded = base64.b64encode(image_data).decode('ascii')
658-
659-
metadata = b'Some data'
660667
metadata_encoded = base64.b64encode(metadata).decode('ascii')
661668

662669
data = {
@@ -768,21 +775,19 @@ def test_not_base64_encoded(
768775
result_code=ResultCodes.FAIL,
769776
)
770777

771-
def test_too_large_foo(
778+
779+
def test_metadata_too_large(
772780
self,
773781
vuforia_database_keys: VuforiaDatabaseKeys,
774782
png_rgb: io.BytesIO,
775783
) -> None:
776784
"""
777-
A base64 encoded string is valid application metadata.
785+
A base64 encoded string of up to 1024 * 1024 bytes is valid application
786+
metadata.
778787
"""
779788
image_data = png_rgb.read()
780789
image_data_encoded = base64.b64encode(image_data).decode('ascii')
781-
782-
# 1000000 not too large
783-
# (1024 * 1024 - 1) is not too large
784-
# (1024 * 1024) is too large
785-
metadata = b'a' * (1024 * 1024)
790+
metadata = b'a' * (1024 * 1024 + 1)
786791
metadata_encoded = base64.b64encode(metadata).decode('ascii')
787792

788793
data = {
@@ -797,4 +802,8 @@ def test_too_large_foo(
797802
data=data,
798803
)
799804

800-
assert_success(response=response)
805+
assert_vws_failure(
806+
response=response,
807+
status_code=codes.UNPROCESSABLE_ENTITY,
808+
result_code=ResultCodes.METADATA_TOO_LARGE,
809+
)

0 commit comments

Comments
 (0)