@@ -410,7 +410,7 @@ def test_image_valid(
410410
411411 assert_success (response = response )
412412
413- def test_bad_image (
413+ def test_bad_image_format_or_color_space (
414414 self ,
415415 bad_image_file : io .BytesIO ,
416416 vuforia_database_keys : VuforiaDatabaseKeys ,
@@ -440,7 +440,7 @@ def test_bad_image(
440440 result_code = ResultCodes .BAD_IMAGE ,
441441 )
442442
443- def test_too_large (
443+ def test_corrupted (
444444 self ,
445445 vuforia_database_keys : VuforiaDatabaseKeys ,
446446 png_large : io .BytesIO ,
@@ -476,6 +476,117 @@ def test_too_large(
476476 result_code = ResultCodes .IMAGE_TOO_LARGE ,
477477 )
478478
479+ def test_jpeg_too_large (
480+ self ,
481+ vuforia_database_keys : VuforiaDatabaseKeys ,
482+ png_large : io .BytesIO ,
483+ ) -> None :
484+ """
485+ foobar todo update docstring
486+ An `ImageTooLarge` result is returned if the image is above a certain
487+ threshold.
488+
489+ This threshold is documented as being 2 MB but it is actually
490+ slightly larger. See the `png_large` fixture for more details.
491+ """
492+ original_data = png_large .getvalue ()
493+ longer_data = original_data .replace (b'IEND' , b'\x00 ' + b'IEND' )
494+ too_large_file = io .BytesIO (longer_data )
495+
496+ image_data = too_large_file .read ()
497+ image_data_encoded = base64 .b64encode (image_data ).decode ('ascii' )
498+
499+ data = {
500+ 'name' : 'example_name' ,
501+ 'width' : 1 ,
502+ 'image' : image_data_encoded ,
503+ }
504+
505+ response = add_target_to_vws (
506+ vuforia_database_keys = vuforia_database_keys ,
507+ data = data ,
508+ )
509+
510+ assert_vws_failure (
511+ response = response ,
512+ status_code = codes .UNPROCESSABLE_ENTITY ,
513+ result_code = ResultCodes .IMAGE_TOO_LARGE ,
514+ )
515+
516+ def test_png_too_large (
517+ self ,
518+ vuforia_database_keys : VuforiaDatabaseKeys ,
519+ png_large : io .BytesIO ,
520+ ) -> None :
521+ """
522+ foobar todo update docstring
523+ An `ImageTooLarge` result is returned if the image is above a certain
524+ threshold.
525+
526+ This threshold is documented as being 2 MB but it is actually
527+ slightly larger. See the `png_large` fixture for more details.
528+ """
529+ original_data = png_large .getvalue ()
530+ longer_data = original_data .replace (b'IEND' , b'\x00 ' + b'IEND' )
531+ too_large_file = io .BytesIO (longer_data )
532+
533+ image_data = too_large_file .read ()
534+ image_data_encoded = base64 .b64encode (image_data ).decode ('ascii' )
535+
536+ data = {
537+ 'name' : 'example_name' ,
538+ 'width' : 1 ,
539+ 'image' : image_data_encoded ,
540+ }
541+
542+ response = add_target_to_vws (
543+ vuforia_database_keys = vuforia_database_keys ,
544+ data = data ,
545+ )
546+
547+ assert_vws_failure (
548+ response = response ,
549+ status_code = codes .UNPROCESSABLE_ENTITY ,
550+ result_code = ResultCodes .IMAGE_TOO_LARGE ,
551+ )
552+
553+ def test_corrupted_and_too_large (
554+ self ,
555+ vuforia_database_keys : VuforiaDatabaseKeys ,
556+ png_large : io .BytesIO ,
557+ ) -> None :
558+ """
559+ foobar todo update docstring
560+ An `ImageTooLarge` result is returned if the image is above a certain
561+ threshold.
562+
563+ This threshold is documented as being 2 MB but it is actually
564+ slightly larger. See the `png_large` fixture for more details.
565+ """
566+ original_data = png_large .getvalue ()
567+ longer_data = original_data .replace (b'IEND' , b'\x00 ' + b'IEND' )
568+ too_large_file = io .BytesIO (longer_data )
569+
570+ image_data = too_large_file .read ()
571+ image_data_encoded = base64 .b64encode (image_data ).decode ('ascii' )
572+
573+ data = {
574+ 'name' : 'example_name' ,
575+ 'width' : 1 ,
576+ 'image' : image_data_encoded ,
577+ }
578+
579+ response = add_target_to_vws (
580+ vuforia_database_keys = vuforia_database_keys ,
581+ data = data ,
582+ )
583+
584+ assert_vws_failure (
585+ response = response ,
586+ status_code = codes .UNPROCESSABLE_ENTITY ,
587+ result_code = ResultCodes .IMAGE_TOO_LARGE ,
588+ )
589+
479590 def test_not_base64_encoded (
480591 self ,
481592 vuforia_database_keys : VuforiaDatabaseKeys ,
0 commit comments