Commit 10445878 authored by Ivan Tyagov's avatar Ivan Tyagov

Only textual conversions can use substitution. Add testing for this change.

parent f7ea2361
......@@ -36,7 +36,7 @@ from Products.ERP5.Document.Document import Document, ConversionError, _MARKER,
from Products.ERP5.Document.File import File
from Products.ERP5Type.WebDAVSupport import TextContent
import re
from Products.ERP5.Document.Document import VALID_IMAGE_FORMAT_LIST
from Products.ERP5.Document.Document import VALID_IMAGE_FORMAT_LIST, VALID_TEXT_FORMAT_LIST
import cStringIO
from string import Template
......@@ -179,6 +179,8 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
self.setConversion(result, original_mime_type, **kw)
else:
mime_type, result = self.getConversion(**kw)
if format in VALID_TEXT_FORMAT_LIST:
# only textual content can be sustituted
if substitution_method_parameter_dict is None:
substitution_method_parameter_dict = {}
result = self._substituteTextContent(result, safe_substitute=safe_substitute,
......
......@@ -2091,7 +2091,9 @@ return 1
image_document.edit(file=upload_file)
web_page_document = self.portal.web_page_module.newContent(portal_type="Web Page")
web_page_document.setTextContent('<b> test </b>')
web_page_document.setTextContent('<b> test </b> $website_url $website_url')
# a Web Page can generate dynamic text so test is as well
web_page_document.setTextContentSubstitutionMappingMethodId('WebPage_getStandardSubstitutionMappingDict')
self.stepTic()
ooo_document_url = '%s/%s' %(self.portal.absolute_url(), ooo_document.getRelativeUrl())
......@@ -2704,8 +2706,8 @@ class TestDocumentPerformance(TestDocumentMixin):
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDocument))
suite.addTest(unittest.makeSuite(TestDocumentWithSecurity))
suite.addTest(unittest.makeSuite(TestDocumentPerformance))
#suite.addTest(unittest.makeSuite(TestDocumentWithSecurity))
#suite.addTest(unittest.makeSuite(TestDocumentPerformance))
return suite
......
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