Commit 8a3e08cf authored by Rafael Monnerat's avatar Rafael Monnerat

"unskip" tests and fix Functional Tests

testERP5WebWithDms will pass now as librsvg is well installed now and
assertion on tests were simplied to become more reliable (it provides
less false positives for image comparation).

The functional test testSurchargeWithInvalidDateTime was improved for
better assertions.
parents 6b0e805d b08ca5f1
......@@ -180,11 +180,35 @@
<td></td>\n
</tr>\n
<tr>\n
<td>assertText</td>\n
<td>//div[@class="status"]/div[@class="transition_message"]</td>\n
<td>Data updated.</td>\n
<td>verifyValue</td>\n
<td>subfield_field_my_start_date_year</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>verifyValue</td>\n
<td>subfield_field_my_start_date_month</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>verifyValue</td>\n
<td>subfield_field_my_start_date_day</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>verifyValue</td>\n
<td>subfield_field_my_start_date_hour</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>verifyValue</td>\n
<td>subfield_field_my_start_date_minute</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertTextNotPresent</td>\n
<td>You did not enter a valid date and time.</td>\n
<td></td>\n
</tr>\n
\n
</tbody></table>\n
</body>\n
</html>
......
......@@ -234,7 +234,7 @@
\n
<tr>\n
<td>click</td>\n
<td>//*[@class=\'listbox-data-line-0 DataA\']//input[@type="checkbox"]</td>\n
<td>//*[@class=\'listbox-data-line-0 DataA\']/*[@class="listbox-table-select-cell"]/input[@type="checkbox"]</td>\n
<td></td>\n
</tr>\n
<tr>\n
......
685
\ No newline at end of file
688
\ No newline at end of file
......@@ -40,7 +40,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5.Document.Document import ConversionError
from Products.ERP5Type.tests.backportUnittest import expectedFailure
try:
from PIL import Image
......@@ -50,6 +49,8 @@ except ImportError:
import Image
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg',)
IMAGE_COMPARE_TOLERANCE = 800
def makeFilePath(name):
return os.path.join(os.path.dirname(__file__), 'test_data', name)
......@@ -806,23 +807,19 @@ return True
# Compare images and accept some minimal difference,
difference_value = compare_image(StringIO(converted_data), expected_image)
self.assertTrue(difference_value < 100,
self.assertTrue(difference_value < IMAGE_COMPARE_TOLERANCE,
"Conversion from svg to png create one too small image, " + \
"so it failed to download the image. (%s >= 100)" % difference_value)
def _testImageConversionFromSVGToPNG_file_url(self, portal_type="Image"):
""" Test Convert one SVG Image with an image using local path (file)
at the url of the image tag. ie:
<image xlink:href="file:///../../user-XXX-XXX"
"so it failed to download the image. (%s >= %s)" % (difference_value,
IMAGE_COMPARE_TOLERANCE))
This is not used by ERP5 in production, but this is way that
prooves that conversion from SVG to PNG can use external images.
def _testImageConversionFromSVGToPNG_url(self, image_url, portal_type="Image"):
""" Test Convert one SVG Image with an image url. ie:
<image xlink:href="xxx:///../../user-XXX-XXX"
"""
portal = self.portal
module = portal.getDefaultModule(portal_type=portal_type)
upload_file = makeFileUpload('user-TESTSVG-CASE-FULLURL-TEMPLATE.svg')
svg_content = upload_file.read().replace("REPLACE_THE_URL_HERE",
"file://" + makeFilePath("user-TESTSVG-BACKGROUND-IMAGE.png"))
upload_file = makeFileUpload('user-TESTSVG-CASE-URL-TEMPLATE.svg')
svg_content = upload_file.read().replace("REPLACE_THE_URL_HERE", image_url)
# Add image using data instead file this time as it is not the goal of
# This test assert this topic.
......@@ -837,13 +834,43 @@ return True
self.assertEquals(image.getContentType(), 'image/svg+xml')
mime, converted_data = image.convert("png")
self.assertEquals(mime, 'image/png')
expected_image = makeFileUpload('user-TESTSVG-CASE-FULLURL.png')
expected_image = makeFileUpload('user-TESTSVG-CASE-URL.png')
# Compare images and accept some minimal difference,
difference_value = compare_image(StringIO(converted_data), expected_image)
self.assertTrue(difference_value < 100,
self.assertTrue(difference_value < IMAGE_COMPARE_TOLERANCE,
"Conversion from svg to png create one too small image, " + \
"so it failed to download the image. (%s >= 100)" % difference_value)
"so it failed to download the image. (%s >= %s)" % (difference_value,
IMAGE_COMPARE_TOLERANCE))
def _testImageConversionFromSVGToPNG_file_url(self, portal_type="Image"):
""" Test Convert one SVG Image with an image using local path (file)
at the url of the image tag. ie:
<image xlink:href="file:///../../user-XXX-XXX"
This is not used by ERP5 in production, but this is way that
prooves that conversion from SVG to PNG can use external images.
"""
image_url = "file://" + makeFilePath("user-TESTSVG-BACKGROUND-IMAGE.png")
self._testImageConversionFromSVGToPNG_url(image_url, portal_type)
def _testImageConversionFromSVGToPNG_http_url(self, portal_type="Image"):
""" Test Convert one SVG Image with an image with a full
url at the url of the image tag. ie:
<image xlink:href="http://www.erp5.com/user-XXX-XXX"
"""
portal = self.portal
module = portal.getDefaultModule(portal_type=portal_type)
upload_file = makeFileUpload('user-TESTSVG-BACKGROUND-IMAGE.png')
background_image = module.newContent(portal_type=portal_type,
file=upload_file,
reference="NXD-BACKGROUND")
background_image.publish()
transaction.commit()
self.tic()
image_url = background_image.absolute_url() + "?format="
self._testImageConversionFromSVGToPNG_url(image_url, portal_type)
def _testImageConversionFromSVGToPNG_broken_url(self, portal_type="Image"):
""" Test Convert one broken SVG into PNG. The expected outcome is a
......@@ -856,11 +883,11 @@ return True
"""
portal = self.portal
module = portal.getDefaultModule(portal_type=portal_type)
upload_file = makeFileUpload('user-TESTSVG-CASE-FULLURL-TEMPLATE.svg')
upload_file = makeFileUpload('user-TESTSVG-CASE-URL-TEMPLATE.svg')
svg_content = upload_file.read().replace("REPLACE_THE_URL_HERE",
"http://soidjsoidjqsoijdqsoidjqsdoijsqd.idjsijds/../user-XXX-XXX")
upload_file = makeFileUpload('user-TESTSVG-CASE-FULLURL-TEMPLATE.svg')
upload_file = makeFileUpload('user-TESTSVG-CASE-URL-TEMPLATE.svg')
svg2_content = upload_file.read().replace("REPLACE_THE_URL_HERE",
"https://www.erp5.com/usXXX-XXX")
......@@ -908,8 +935,6 @@ return True
self.assertEquals(image.getContentType(), 'image/svg+xml')
self.assertRaises(ConversionError, image.convert, "png")
# "Waiting for rsvg-convert be available for imagemagick"
@expectedFailure
def test_ImageConversionFromSVGToPNG_embeeded_data(self):
""" Test Convert one SVG Image with an image with the data
at the url of the image tag.ie:
......@@ -917,7 +942,6 @@ return True
"""
self._testImageConversionFromSVGToPNG("Image")
@expectedFailure
def test_FileConversionFromSVGToPNG_embeeded_data(self):
""" Test Convert one SVG Image with an image with the data
at the url of the image tag.ie:
......@@ -925,7 +949,6 @@ return True
"""
self._testImageConversionFromSVGToPNG("File")
@expectedFailure
def test_WebPageConversionFromSVGToPNG_embeeded_data(self):
""" Test Convert one SVG Image with an image with the data
at the url of the image tag.ie:
......@@ -958,7 +981,6 @@ return True
"""
self._testImageConversionFromSVGToPNG_empty_file("File")
@expectedFailure
def test_ImageConversionFromSVGToPNG_file_url(self):
""" Test Convert one SVG Image with an image using local path (file)
at the url of the image tag. ie:
......@@ -969,7 +991,6 @@ return True
"""
self._testImageConversionFromSVGToPNG_file_url("Image")
@expectedFailure
def test_FileConversionFromSVGToPNG_file_url(self):
""" Test Convert one SVG Image with an image using local path (file)
at the url of the image tag. ie:
......@@ -980,7 +1001,6 @@ return True
"""
self._testImageConversionFromSVGToPNG_file_url("File")
@expectedFailure
def test_WebPageConversionFromSVGToPNG_file_url(self):
""" Test Convert one SVG Image with an image using local path (file)
at the url of the image tag. ie:
......@@ -991,32 +1011,26 @@ return True
"""
self._testImageConversionFromSVGToPNG_file_url("Web Page")
@expectedFailure
def test_ImageConversionFromSVGToPNG_http_url(self):
""" Test Convert one SVG Image with an image with a full
url at the url of the image tag. ie:
<image xlink:href="http://www.erp5.com/user-XXX-XXX"
"""
self._testImageConversionFromSVGToPNG(
"Image", "user-TESTSVG-CASE-FULLURL")
self._testImageConversionFromSVGToPNG_http_url("Image")
@expectedFailure
def test_FileConversionFromSVGToPNG_http_url(self):
""" Test Convert one SVG Image with an image with a full
url at the url of the image tag. ie:
<image xlink:href="http://www.erp5.com/user-XXX-XXX"
"""
self._testImageConversionFromSVGToPNG(
"File", "user-TESTSVG-CASE-FULLURL")
self._testImageConversionFromSVGToPNG_http_url("File")
@expectedFailure
def test_WebPageConversionFromSVGToPNG_http_url(self):
""" Test Convert one SVG Image with an image with a full
url at the url of the image tag. ie:
<image xlink:href="http://www.erp5.com/user-XXX-XXX"
"""
self._testImageConversionFromSVGToPNG(
"Web Page", "user-TESTSVG-CASE-FULLURL")
self._testImageConversionFromSVGToPNG_http_url("Web Page")
def test_suite():
suite = unittest.TestSuite()
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
version="1.1"
inkscape:version="0.48.2 r9819"
width="524.40942"
height="372.04724"
sodipodi:docname="user-howto.manage.support.requests.assign.event.to.ticket.create.follow.up.ticket-002-en.svg">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1024"
inkscape:window-height="718"
id="namedview4"
showgrid="false"
inkscape:zoom="1.3707937"
inkscape:cx="270.63548"
inkscape:cy="273.56415"
inkscape:window-x="-3"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<image
y="0.99838382"
x="0.11206181"
id="image3065"
xlink:href="http://www.erp5.com/user-howto.manage.support.requests.assign.event.to.ticket.create.follow.up.ticket.screenshot?format=png"
height="369.32098"
width="523.56" />
<rect
style="fill:none;stroke:#ff0000;stroke-width:2.696;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2987"
width="81.987816"
height="11.938368"
x="64.116737"
y="43.860283"
rx="2.5779424"
ry="0.29129499" />
<rect
style="fill:none;stroke:#ff0000;stroke-width:2.81803679;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2989"
width="82.598396"
height="9.534873"
x="64.417244"
y="68.28804"
rx="2.4387791"
ry="0.28804284" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path3898"
sodipodi:cx="303.51724"
sodipodi:cy="155.48277"
sodipodi:rx="25.13793"
sodipodi:ry="25.13793"
d="m 328.65517,155.48277 a 25.13793,25.13793 0 1 1 -50.27586,0 25.13793,25.13793 0 1 1 50.27586,0 z"
transform="matrix(0.63956863,0,0,0.63956863,-19.039052,-62.99123)" />
<text
xml:space="preserve"
style="font-size:23px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
x="166.65985"
y="45.086403"
id="text3900"
sodipodi:linespacing="125%"
transform="scale(1.0034798,0.99653226)"><tspan
sodipodi:role="line"
id="tspan3902"
x="166.65985"
y="45.086403">1</tspan></text>
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path3898-3"
sodipodi:cx="303.51724"
sodipodi:cy="155.48277"
sodipodi:rx="25.13793"
sodipodi:ry="25.13793"
d="m 328.65517,155.48277 a 25.13793,25.13793 0 1 1 -50.27586,0 25.13793,25.13793 0 1 1 50.27586,0 z"
transform="matrix(0.63956863,0,0,0.63956863,-17.252115,-25.057001)" />
<text
xml:space="preserve"
style="font-size:23px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#0000ff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
x="168.57806"
y="83.152695"
id="text3900-2"
sodipodi:linespacing="125%"
transform="scale(1.0034798,0.99653226)"><tspan
sodipodi:role="line"
id="tspan3902-0"
x="168.57806"
y="83.152695">2</tspan></text>
</svg>
......@@ -32,7 +32,7 @@
id="defs6" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
bordercolor="#000000"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
......@@ -58,7 +58,7 @@
height="369.32098"
width="523.56" />
<rect
style="fill:none;stroke:#ff0000;stroke-width:2.696;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
style="fill:none;stroke:#000000;stroke-width:2.696;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2987"
width="81.987816"
height="11.938368"
......@@ -67,7 +67,7 @@
rx="2.5779424"
ry="0.29129499" />
<rect
style="fill:none;stroke:#ff0000;stroke-width:2.81803679;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
style="fill:none;stroke:#000000;stroke-width:2.81803679;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2989"
width="82.598396"
height="9.534873"
......@@ -87,7 +87,7 @@
transform="matrix(0.63956863,0,0,0.63956863,-19.039052,-62.99123)" />
<text
xml:space="preserve"
style="font-size:23px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
style="font-size:23px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
x="166.65985"
y="45.086403"
id="text3900"
......@@ -109,7 +109,7 @@
transform="matrix(0.63956863,0,0,0.63956863,-17.252115,-25.057001)" />
<text
xml:space="preserve"
style="font-size:23px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#0000ff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
style="font-size:23px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
x="168.57806"
y="83.152695"
id="text3900-2"
......
......@@ -32,7 +32,6 @@ from Products.ERP5Form.Form import ERP5Form
from DocumentTemplate import String
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase
from Products.ERP5OOo.tests.utils import Validator
......@@ -125,7 +124,6 @@ class TestOOoChart(ERP5TypeTestCase, ZopeTestCase.Functional):
if error_list:
self.fail(''.join(error_list))
@expectedFailure
def test_ooo_chart(self):
portal = self.getPortal()
# Does the form exist ?
......@@ -229,7 +227,6 @@ class TestOOoChart(ERP5TypeTestCase, ZopeTestCase.Functional):
# Test Validation Relax NG
self._validate(body)
@expectedFailure
def test_proxy_ooo_chart(self):
portal = self.getPortal()
# Does the form exist ?
......
......@@ -30,6 +30,8 @@ import urllib2
from lxml import etree
from Products.ERP5.Document.Document import ConversionError
SVG_DEFAULT_NAMESPACE = "http://www.w3.org/2000/svg"
def getDataURI(url):
try:
data = urllib2.urlopen(url)
......@@ -45,8 +47,14 @@ def transformUrlToDataURI(content):
root = etree.fromstring(content)
# Prevent namespace contains "None" included into svg by mistake
# and fix svg definition as in some images the namespace is not
# well defined by using xmlns="http://www.w3.org/2000/svg" instead
# of xmlns:svg="http://www.w3.org/2000/svg".
namespace_dict = root.nsmap.copy()
namespace_dict.pop(None, "discard")
discarted = namespace_dict.pop(None, "discard")
if discarted == SVG_DEFAULT_NAMESPACE or \
"svg" not in namespace_dict:
namespace_dict["svg"] = SVG_DEFAULT_NAMESPACE
# Get all images which uses xlink:href
image_list = root.xpath("//svg:image[@xlink:href]", namespaces=namespace_dict)
......
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