@@ -1079,7 +1079,7 @@ def test_png(
10791079 We do not test exactly at this limit, but that may be beneficial in the
10801080 future.
10811081 """
1082- documented_max_bytes = 2 * 1024 * 1024
1082+ max_bytes = 2 * 1024 * 1024
10831083 width = height = 835
10841084 png_not_too_large = make_image_file (
10851085 file_format = 'PNG' ,
@@ -1096,8 +1096,8 @@ def test_png(
10961096 # maximum file size.
10971097 #
10981098 # This is just because of the implementation details of ``image_file``.
1099- assert image_content_size < documented_max_bytes
1100- assert (image_content_size * 1.05 ) > documented_max_bytes
1099+ assert image_content_size < max_bytes
1100+ assert (image_content_size * 1.05 ) > max_bytes
11011101
11021102 response = query (
11031103 vuforia_database_keys = vuforia_database_keys ,
@@ -1122,20 +1122,80 @@ def test_png(
11221122 # maximum file size.
11231123 #
11241124 # This is just because of the implementation details of ``image_file``.
1125- assert image_content_size > documented_max_bytes
1126- assert (image_content_size * 0.95 ) < documented_max_bytes
1125+ assert image_content_size > max_bytes
1126+ assert (image_content_size * 0.95 ) < max_bytes
11271127
11281128 with pytest .raises (requests .exceptions .ConnectionError ):
11291129 query (
11301130 vuforia_database_keys = vuforia_database_keys ,
11311131 body = body ,
11321132 )
11331133
1134- def test_jpeg (self ) -> None :
1134+ def test_jpeg (
1135+ self ,
1136+ vuforia_database_keys : VuforiaDatabaseKeys ,
1137+ ) -> None :
11351138 """
1136- See https://github.com/adamtheturtle/vws-python/issues/357 for
1137- implementing this test.
1139+ According to
1140+ https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query.
1141+ the maximum file size is "512 KiB for JPEG".
1142+ However, this test shows that the maximum size for JPEG is 2 MiB.
1143+
1144+ Above this limit, a ``ConnectionError`` is raised.
1145+ We do not test exactly at this limit, but that may be beneficial in the
1146+ future.
11381147 """
1148+ max_bytes = 2 * 1024 * 1024
1149+ width = height = 1864
1150+ png_not_too_large = make_image_file (
1151+ file_format = 'JPEG' ,
1152+ color_space = 'RGB' ,
1153+ width = width ,
1154+ height = height ,
1155+ )
1156+
1157+ image_content = png_not_too_large .getvalue ()
1158+ body = {'image' : ('image.jpeg' , image_content , 'image/jpeg' )}
1159+
1160+ image_content_size = len (image_content )
1161+ # We check that the image we created is just slightly smaller than the
1162+ # maximum file size.
1163+ #
1164+ # This is just because of the implementation details of ``image_file``.
1165+ assert image_content_size < max_bytes
1166+ assert (image_content_size * 1.05 ) > max_bytes
1167+
1168+ response = query (
1169+ vuforia_database_keys = vuforia_database_keys ,
1170+ body = body ,
1171+ )
1172+
1173+ assert_query_success (response = response )
1174+ assert response .json ()['results' ] == []
1175+
1176+ width = height = 1865
1177+ png_not_too_large = make_image_file (
1178+ file_format = 'JPEG' ,
1179+ color_space = 'RGB' ,
1180+ width = width ,
1181+ height = height ,
1182+ )
1183+
1184+ image_content = png_not_too_large .getvalue ()
1185+ body = {'image' : ('image.jpeg' , image_content , 'image/jpeg' )}
1186+ image_content_size = len (image_content )
1187+ # We check that the image we created is just slightly larger than the
1188+ # maximum file size.
1189+ #
1190+ # This is just because of the implementation details of ``image_file``.
1191+ assert image_content_size > max_bytes
1192+ assert (image_content_size * 0.95 ) < max_bytes
1193+
1194+ with pytest .raises (requests .exceptions .ConnectionError ):
1195+ query (
1196+ vuforia_database_keys = vuforia_database_keys ,
1197+ body = body ,
1198+ )
11391199
11401200
11411201@pytest .mark .usefixtures ('verify_mock_vuforia' )
0 commit comments