Commit 17e92034 authored by Jérome Perrin's avatar Jérome Perrin

corporate_identity_test: use PNG files for reference data

BMP are not compressed and use more disk space than PNG.
The trick is that ERP5 uses by default a quality of 75% on images ([this is default on propertysheet])
so we need to dump the image with maximum (100%) quality.

Update also assertion message to not include the full base64
image in case of difference, use a short assertion message
and save images in log folder.

[this is default on propertysheet]: https://lab.nexedi.com/nexedi/erp5/blob/2f9b67fae3ac59955231d4191a34134ff1b6079a/product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/HtmlStylePreference/preferred_image_quality_property.xml#L56
parent 59fe5071
Pipeline #14519 failed with stage
in 0 seconds
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>602161ce4545becc5ab6757e7e5522f9</string> </value>
<value> <string>dc9dc7a936eaea6fb5fcfc3c96358281</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>3f342b9c09131adf3f6b0f37a9ceac9c</string> </value>
<value> <string>61e8065722446479d46e5fc047e2c267</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>75ec36fedb7d0f0977c0334fb20c616e</string> </value>
<value> <string>e2357fee6dcf7eaf6496abedaf3703f1</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -87,11 +87,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>ce5bc5604fe043792a69d1ee44bd2196</string> </value>
<value> <string>8c8d58b0d4c330652bcd6f8019de1a9a</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-ms-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>6bd59a9c0c273d86048097b8f1ad899d</string> </value>
<value> <string>aeb2cc625ea2e191474803f7a7e622dd</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -87,11 +87,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>e9be887e25fe13b5c87fb3d5a985456d</string> </value>
<value> <string>dcd96ee7e86c270d67837dc1081ef441</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-ms-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>7bf32739ce469e3d5f9227944bd08c90</string> </value>
<value> <string>92a9105f95b2643122ca48cf50e93b7f</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>0ed6524c4084a10b5fce633ad75f16d2</string> </value>
<value> <string>bb8c27acefcab05e1f12268fd21a3a7f</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>36714bf753f927a01c4c631bdab7d825</string> </value>
<value> <string>700b255d54be3782ee6791209aac7ed4</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>852236dc9379bfd4f91445fd4d01dcea</string> </value>
<value> <string>ed1fbb0b8f12b7bb7f154a17fe329dac</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>d54ad51a0ba28613fa76172e94e63320</string> </value>
<value> <string>17f299c4d437ac4a2cc571789dc1837b</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>ab4099494e42dcc867b4edae911e6508</string> </value>
<value> <string>99a96aa00bb2fce2c55de74fc395c135</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>1f28039d404adc23142342f7d6654364</string> </value>
<value> <string>9eddca460421cf4f82cfb0e550ef4c5b</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>9e4f1c8416e0cfb1df66ad65f78166c9</string> </value>
<value> <string>997c3c23638f6cde2c3a1a96983e785c</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>edbd8f387ade29569aa1db37e1dc756b</string> </value>
<value> <string>7162876510cdc77ec72a2078682539ac</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>3c68ea21fb25f8b83fe6908fee0164a2</string> </value>
<value> <string>34ed812dbd10d36644680bfa60b9a796</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>3b6af83be3f9f958b768030967345da3</string> </value>
<value> <string>b04b9c056e7390436a3709012800d452</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>bad17ec47b3b1e892d1832c8497c7d87</string> </value>
<value> <string>750981bccb0809bf33b78b9501c62869</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>cb29d44fd74c8d11afa17a95e6767156</string> </value>
<value> <string>9af8a5a6f5b2b1ec2e5d1141a87ce789</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>92a0def90cf6561e214e1c09de4b3d96</string> </value>
<value> <string>a58ccc52806f53ffc14c252d0dea6d1b</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>49afdaf94a2b72834b2e73fe618a2d92</string> </value>
<value> <string>f75c8d86539794f7c68e6a104a90c621</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -85,11 +85,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>4eae92db6c336a7b56b51455694e533f</string> </value>
<value> <string>7a9edc20e801afcbde683cc4e40c3856</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>53032bd9ff781e0aff1dc6bec1a69997</string> </value>
<value> <string>5ebfa2a106894c3e46ebe5c048d2428a</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>863b226b9a44c0d839044e90a36544b5</string> </value>
<value> <string>a99450a3b98c32e54bb2d9165ec0e001</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>854ac49c24a4c58b43ea3bc8c0d1bf62</string> </value>
<value> <string>c7fa5998f95e4a01db1fa3bb23def696</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>616c0628cd7dc1debaed1d2558275fe3</string> </value>
<value> <string>c79671bc2e82be3fe811d5f7d2668ca9</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>59d7bf19acdbf7b657908aa119bde08a</string> </value>
<value> <string>bc660881efcb4b752c3cb968ca34a888</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>c4f85a79732d6e218f4897ec40dd92e3</string> </value>
<value> <string>6efc4d80889241ea02bfaa0222938a87</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>49afdaf94a2b72834b2e73fe618a2d92</string> </value>
<value> <string>ab79319560ba39a524bbde8efa04d1c1</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>f2841e1fedb7255533c5904862bfa6ca</string> </value>
<value> <string>31a82df2c6e18805b6eb99d425d4aa25</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>604f59988f92a7d5fb7ca004354733ed</string> </value>
<value> <string>3fd1e55a0f8faa60f60babb5f61c60b5</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>8dd4ece0e5b0ba3adf78433664e341ca</string> </value>
<value> <string>982d0bb429134cd89f41a3e5fad607f5</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>8dd4ece0e5b0ba3adf78433664e341ca</string> </value>
<value> <string>3fb50af8421bfa18cad11463bda76a52</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>61c7761c9634e9261210fdad1d67ae8d</string> </value>
<value> <string>2966c97ca364bfe68076c72525b37794</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>409b5d5406d33d2cd442f94b9e815735</string> </value>
<value> <string>11e1cd99e0f64369fe083105d9130353</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>9fdf281f148030d11f0f3e72c1057e10</string> </value>
<value> <string>a9d6661fffa2942775e2f865cdee3425</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>2626ba4fdccf0499328802854e04749b</string> </value>
<value> <string>e08ce5d18c10260ed6e3596ae55588c9</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>16c650c82a9cebef9f17ede26bd37293</string> </value>
<value> <string>12445cf735404ece7cba0ea3a9a639ce</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>4fdffce4a737f10572cc3ee4edec0104</string> </value>
<value> <string>97641f4851ddd3fe0965268a957d6ee0</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>c26594b3801a6a02d79dd8245cef99e0</string> </value>
<value> <string>72891a161589f8bd7ed13ae639ab9092</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -79,11 +79,11 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>bbdb48ec9b247a07e0dea40a2c5be0e7</string> </value>
<value> <string>72e54d75d0af25a6ae647691d82342fb</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
......
......@@ -30,8 +30,8 @@ from Products.Localizer.itools.i18n.accept import AcceptLanguage
from PIL import Image
import cStringIO
import math
import io
import base64
import os.path
def changeSkin(skin_name):
"""
......@@ -135,21 +135,18 @@ class TestCorporateIdentityTemplateList(ERP5TypeTestCase):
# - rms is ~1.0 if date is 2017-06-07 vs 2017-06-06 with bmp images
return rms
def convertToPng(self, img_data):
bmp_file = Image.open(io.BytesIO(img_data))
img_buff = cStringIO.StringIO()
bmp_file.save(img_buff, format='PNG', optimize=True, quality=75)
img_data = img_buff.getvalue()
return ''.join(['data:image/png;base64,', base64.encodestring(img_data)])
def assertImageRenderingEquals(self, test_image_data, expected_image_data, message="Images rendering differs", max_rms=10.0):
rms = self.computeImageRenderingRootMeanSquare(test_image_data, expected_image_data)
if rms <= max_rms:
return
raise AssertionError("%(message)s\nComparing rendered image:\n%(base64_1)s\nWith expected image:\n%(base64_2)s\nRMS: %(rms)s > %(max_rms)s\nAssertionError: %(message)s" % {
from Products.ERP5Type.tests.runUnitTest import log_directory
if log_directory:
with open(os.path.join(log_directory, '%s-expected.png' % self.id()), 'wb') as f:
f.write(expected_image_data)
with open(os.path.join(log_directory, '%s-actual.png' % self.id()), 'wb') as f:
f.write(test_image_data)
raise AssertionError("%(message)s\nRMS: %(rms)s > %(max_rms)s\nAssertionError: %(message)s" % {
"message": message,
"base64_1": self.convertToPng(test_image_data),
"base64_2": self.convertToPng(expected_image_data),
"rms": rms,
"max_rms": max_rms,
})
......@@ -256,13 +253,13 @@ class TestCorporateIdentityTemplateList(ERP5TypeTestCase):
)
self.login()
image_source_pdf_doc.setData(pdf_data)
_, bmp = image_source_pdf_doc.convert("bmp", frame=kw.get("page_number"))
_, png = image_source_pdf_doc.convert("png", frame=kw.get("page_number"), quality=100)
# update bmp files
# update reference files
if dump:
expected_image.setData(bmp)
expected_image.setData(png)
self.tic()
self.assertImageRenderingEquals(str(bmp), str(expected_image.getData()))
self.assertImageRenderingEquals(str(png), str(expected_image.getData()))
##############################################################################
# What rendering is tested:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment