Skip to content

Commit 827f040

Browse files
committed
Progress towards tests which show error
1 parent 862d6d1 commit 827f040

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

dev-requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
attrs==18.1.0 # Modern attrs is required for pytest
2-
autoflake==1.2
3-
bitmath==1.3.1.2
4-
check-manifest==0.37
2+
autoflake==1.2check-manifest==0.37
53
codecov==2.0.15 # Upload coverage data
64
dodgy==0.1.9 # Look for uploaded secrets
75
flake8==3.5.0 # Lint

tests/mock_vws/test_query.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)