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

testXHTML: use self.publish to get HTML source

This is more realistic, because a real HTTP request will use
ZPublisher.BaseRequest.BaseRequest.traverse, which has slightly
different behaviour than getting the form on the context of document.

The behavior becomes different for documents which do some logic on
traversal (like for example the web sites changing the skin).
parent 2b6afa33
......@@ -27,6 +27,7 @@
#
##############################################################################
import cgi
import unittest
import os
import requests
......@@ -34,6 +35,7 @@ from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from subprocess import Popen, PIPE
from AccessControl import getSecurityManager
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import addUserToDeveloperRole, findContentChain
......@@ -674,9 +676,20 @@ def makeTestMethod(validator, portal_type, view_name, bt_name):
self.portal,
portal_type)
document = createSubContent(module, portal_type_list)
view = getattr(document, view_name)
response = self.publish(
'%s/%s' % (document.getPath(), view_name),
user=str(getSecurityManager().getUser()),
handle_errors=False,
)
charset = 'iso8859-15'
content_type = response.getHeader('content-type')
if content_type:
_, params = cgi.parse_header(content_type)
charset = params.get('charset', charset)
self.assert_(*validate_xhtml( validator=validator,
source=view(),
source=response.getBody().decode(charset),
view_name=view_name,
bt_name=bt_name))
return testMethod
......@@ -757,6 +770,8 @@ def test_suite():
# One way to fix this would be to allow a custom "init script" to be called
# on a portal type.
'test_erp5_simulation_Solver_Decision_SolverDecision_viewConfiguration',
# this view redirects to an external URL
'test_erp5_web_Static_Web_Site_WebSite_view',
))
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestXHTML))
......
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