Commit f32d638d authored by Jérome Perrin's avatar Jérome Perrin

tests: make sure ui test page templates can be rendered

In case there is an error in the TALES experession and the page cannot
be rendered, then this page will silently be ignored.
parent 8f84db8e
...@@ -35,6 +35,7 @@ import subprocess ...@@ -35,6 +35,7 @@ import subprocess
import shutil import shutil
import transaction import transaction
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions.ExceptionFormatter import format_exception
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \
_getConversionServerDict _getConversionServerDict
...@@ -405,8 +406,30 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase): ...@@ -405,8 +406,30 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
return True return True
return False return False
def testCheckZuitePageTemplatesValidHTML(self):
# Check the zuite page templates can be rendered, because selenium test
# runner does not report error in case there are errors in the page
# template.
tests_tool = self.portal.portal_tests
for page_template_path, page_template in tests_tool.ZopeFind(
tests_tool, obj_metatypes=['Page Template'], search_sub=1):
try:
page_template.pt_render()
except (KeyboardInterrupt, SystemExit):
raise
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
self.fail('Rendering of %s failed with error:\n%s' % (
page_template_path,
''.join(format_exception(
exc_type,
exc_value,
exc_traceback,
as_html=False))))
def testFunctionalTestRunner(self): def testFunctionalTestRunner(self):
# first of all, abort to get rid of the mysql participation inn this # first of all, abort to get rid of the mysql participation in this
# transaction # transaction
self.portal._p_jar.sync() self.portal._p_jar.sync()
......
  • I also tried to validate that the page template are html valid, but none of them have a doctype, so w3c validator complained for that.

    I gave up after this patch:

    diff --git a/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py b/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
    index d48b576..0e84f22 100644
    --- a/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
    +++ b/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
    @@ -36,6 +36,7 @@ import shutil
     import transaction
     from ZPublisher.HTTPResponse import HTTPResponse
     from zExceptions.ExceptionFormatter import format_exception
    +from Products.ERP5.tests.testXHTML import validator, validate_xhtml
     from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \
                                                    _getConversionServerDict
     
    @@ -414,7 +415,7 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
         for page_template_path, page_template in tests_tool.ZopeFind(
                   tests_tool, obj_metatypes=['Page Template'], search_sub=1):
           try:
    -        page_template.pt_render()
    +        source = page_template.pt_render()
           except (KeyboardInterrupt, SystemExit):
             raise
           except:
    @@ -426,6 +427,18 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
                 exc_value,
                 exc_traceback,
                 as_html=False))))
    +      else:
    +        if validator:
    +          # XXX testXHTML just expose a validator already initialised,
    +          # without the ability to control show_warnings.
    +          # test zuite page have no doctype
    +          validator.show_warnings = False
    +
    +          self.assert_(*validate_xhtml(
    +            validator=validator,
    +            source=source,
    +            view_name=page_template_path,
    +            bt_name=''))
     
     
       def testFunctionalTestRunner(self):
  • mentioned in commit 0cb72f9b

    Toggle commit list
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