Skip to content

Commit e16b183

Browse files
committed
Add metadata tests to update
1 parent fd01efe commit e16b183

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

tests/mock_vws/test_update_target.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,25 @@ class TestApplicationMetadata:
347347
Tests for the application metadata parameter.
348348
"""
349349

350+
_MAX_METADATA_BYTES = 1024 * 1024 - 1
351+
352+
@pytest.mark.parametrize(
353+
'metadata',
354+
[
355+
b'a',
356+
b'a' * _MAX_METADATA_BYTES,
357+
],
358+
ids=['Short', 'Max length'],
359+
)
350360
def test_base64_encoded(
351361
self,
352362
vuforia_database_keys: VuforiaDatabaseKeys,
353363
target_id: str,
364+
metadata: bytes,
354365
) -> None:
355366
"""
356367
A base64 encoded string is valid application metadata.
357368
"""
358-
metadata = b'Some data'
359369
metadata_encoded = base64.b64encode(metadata).decode('ascii')
360370

361371
wait_for_target_processed(
@@ -432,6 +442,35 @@ def test_not_base64_encoded(
432442
result_code=ResultCodes.FAIL,
433443
)
434444

445+
def test_metadata_too_large(
446+
self,
447+
vuforia_database_keys: VuforiaDatabaseKeys,
448+
target_id: str,
449+
) -> None:
450+
"""
451+
A base64 encoded string of greater than 1024 * 1024 bytes is too large
452+
for application metadata.
453+
"""
454+
metadata = b'a' * (self._MAX_METADATA_BYTES + 1)
455+
metadata_encoded = base64.b64encode(metadata).decode('ascii')
456+
457+
wait_for_target_processed(
458+
vuforia_database_keys=vuforia_database_keys,
459+
target_id=target_id,
460+
)
461+
462+
response = update_target(
463+
vuforia_database_keys=vuforia_database_keys,
464+
data={'application_metadata': metadata_encoded},
465+
target_id=target_id,
466+
)
467+
468+
assert_vws_failure(
469+
response=response,
470+
status_code=codes.UNPROCESSABLE_ENTITY,
471+
result_code=ResultCodes.METADATA_TOO_LARGE,
472+
)
473+
435474

436475
@pytest.mark.usefixtures('verify_mock_vuforia')
437476
class TestTargetName:

0 commit comments

Comments
 (0)