@@ -1071,16 +1071,19 @@ class TestMaximumImageSize:
10711071 # width = 1
10721072 # height = int(max_size / 2)
10731073
1074- # Also test max megapixels
1074+ # Also test the maximum size in megapixels
10751075
10761076 def test_png (
10771077 self ,
10781078 vuforia_database_keys : VuforiaDatabaseKeys ,
10791079 ) -> None :
10801080 """
1081- See https://github.com/adamtheturtle/vws-python/issues/357 for
1082- implementing this test.
1081+ According to
1082+ https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query.
1083+ the maximum file size is "2MiB for PNG".
1084+
10831085 """
1086+ documented_max_bytes = 2 * 1024 * 1024
10841087 width = height = 835
10851088 png_not_too_large = image_file (
10861089 file_format = 'PNG' ,
@@ -1093,7 +1096,12 @@ def test_png(
10931096 body = {'image' : ('image.jpeg' , image_content , 'image/jpeg' )}
10941097
10951098 image_content_size = len (image_content )
1096- assert image_content
1099+ # We check that the image we created is just slightly smaller than the
1100+ # maximum file size.
1101+ #
1102+ # This is just because of the implementation details of ``image_file``.
1103+ assert image_content_size < documented_max_bytes
1104+ assert (image_content_size * 1.1 ) > documented_max_bytes
10971105
10981106 response = query (
10991107 vuforia_database_keys = vuforia_database_keys ,
@@ -1113,6 +1121,12 @@ def test_png(
11131121
11141122 image_content = png_not_too_large .getvalue ()
11151123 body = {'image' : ('image.jpeg' , image_content , 'image/jpeg' )}
1124+ # We check that the image we created is just slightly smaller than the
1125+ # maximum file size.
1126+ #
1127+ # This is just because of the implementation details of ``image_file``.
1128+ # assert image_content_size > documented_max_bytes
1129+ # assert (image_content_size * 0.9) < documented_max_bytes
11161130
11171131 image_content_size = len (image_content )
11181132
0 commit comments