Commit b45ffb8b authored by Gabriel Monnerat's avatar Gabriel Monnerat

rename script and add test for this script

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45383 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f87be910
......@@ -55,27 +55,22 @@
catalog_object = context.portal_catalog.getResultValue(path=document_path)\n
document = context.restrictedTraverse(catalog_object.getPath())\n
\n
catalog_object = context.portal_catalog.getResultValue(path=webpage_path)\n
webpage_document = context.restrictedTraverse(catalog_object.getPath())\n
context.setTextContent(document.asStrippedHTML())\n
context.setTitle(document.getTitle())\n
\n
webpage_document.setTextContent(document.asStrippedHTML())\n
webpage_document.setTitle(document.getTitle())\n
\n
if document.getTitle() != webpage_document.getTitle() or document.getId() == webpage_document.getTitle():\n
print dumps(dict(status=400))\n
return printed\n
if document.getTitle() != context.getTitle() or document.getId() == context.getTitle():\n
return dumps(dict(status=400))\n
\n
print dumps(dict(status=200))\n
return printed\n
return dumps(dict(status=200))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>document_path, webpage_path</string> </value>
<value> <string>document_path</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_updateWebDocument</string> </value>
<value> <string>WebPage_updateWebDocument</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -72,9 +72,8 @@ function showNotImplementedMessage(tag){\n
\n
function updateWebPage(){\n
var parameterList = getUrlParameterList();\n
url = "Base_updateWebDocument?document_path=" + \n
parameterList.document_path + \n
"&webpage_path=" + parameterList.webpage_path;\n
url = "WebPage_updateWebDocument?document_path=" + \n
parameterList.document_path;\n
$.get(url, {}, function(data, textStatus, XMLHttpRequest){\n
response = jQuery.parseJSON(data);\n
if (response.status != 200){\n
......
......@@ -27,7 +27,11 @@
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from DateTime import DateTime
import os.path
import Products.ERP5.tests
import re
import json
......@@ -73,6 +77,14 @@ class TestUNG(ERP5TypeTestCase):
"""Clean up form"""
self.portal.REQUEST.form.clear()
def getDocumentPath(self):
""" It returns a full path of document """
folder_path = os.path.dirname(Products.ERP5.tests.__file__)
filename = "tiolive-ERP5.Freedom.TioLive.Spreadsheet-001-en.ods"
return os.path.join(folder_path,
"test_data",
filename), filename
def assertCreateDocumentUsingTemplate(self, template, **kw):
web_page_module = self.portal.web_page_module
self.portal.ERP5Site_createNewWebDocument(template)
......@@ -418,4 +430,26 @@ class TestUNG(ERP5TypeTestCase):
kw["portal_type"] = "Web Table"
result_list = self.portal.web_site_module.ung.WebSection_getWebPageObjectList(**kw)
self.assertEquals(len(result_list), 1)
self.assertEquals(result_list[0].getPortalType(), "Web Table")
\ No newline at end of file
self.assertEquals(result_list[0].getPortalType(), "Web Table")
def testWebPage_updateWebDocument(self):
""" """
portal = self.portal
portal_preferences = portal.portal_preferences
web_page_module = portal.web_page_module
portal_contributions = portal.portal_contributions
system_preference = portal_preferences.newContent(portal_type='System Preference')
conversion_dict = _getConversionServerDict()
system_preference.setPreferredOoodocServerAddress(conversion_dict["hostname"])
system_preference.setPreferredOoodocServerPortNumber(conversion_dict["port"])
system_preference.enable()
self.stepTic()
document_path, filename = self.getDocumentPath()
file = FileUpload(document_path, filename)
document = portal_contributions.newContent(file=file)
web_page = web_page_module.newContent(portal_type="Web Page")
self.stepTic()
web_page.WebPage_updateWebDocument(document.getPath())
self.stepTic()
self.assertTrue(re.search("\>tiolive\<", web_page.getTextContent()) is not None)
self.assertEquals(web_page.getTitle(), document.getTitle())
351
\ No newline at end of file
352
\ No newline at end of file
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