Commit d5564ccf authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_run_my_doc: move extension and test to portal_components

Also remove unused broken function
parent 44380d16
......@@ -7,7 +7,7 @@ def parseTestReport(text):
parser.feed(text)
root = parser.close()
table = root.xpath('//table[@id="SELENIUM-TEST"]')[0]
report = {}
report = dict()
header = table[0][0]
report['status'] = header.attrib['class'].find('passed') > -1
report['name'] = header[0].text
......@@ -49,59 +49,9 @@ def parseTestReport(text):
del element.attrib['style']
for child in element:
stack.append(child)
return dict(title = title, text = lxml.html.tostring(html))
"""
"""
Parse a HTML page and return a list of dictionnaries with the chapters and the tests they contain
"""
def parseTutorial(text):
from Products.ERP5Type.Document import newTempBase
from lxml import etree
parser = etree.HTMLParser(remove_comments=True)
parser.feed(text)
root = parser.close()
table_list = root.xpath('//table[@id="SELENIUM-TEST"]')
table = table_list[0]
listbox = []
i = 0
# Insert only the content of tbody
for table in table_list:
listbox.append(newTempBase(context.getPortalObject(),
'',
title = "Tested Chapter " + str(i),
tag = 'h1'))
if len(table) > 0:
for row in table[-1]:
if(row.tag.lower() == 'tr'):
listbox.append(newTempBase(context.getPortalObject(),
'',
title = row[0][0].text,
tag = 'tr',
arg0 = row[0][1].text,
arg1 = row[0][2].text))
else:
listbox.append(newTempBase(context.getPortalObject(),
'',
title = row[0][0].text,
tag = 'tr',
arg0 = row[0][1].text,
arg1 = row[0][2].text))
stack = [html[1]]
# Let's display everything in the test by removing the style attributes (they're not supposed to have any style attributes at all during the tests)
while stack:
element = stack.pop()
if element.attrib.has_key('style'):
del element.attrib['style']
for child in element:
stack.append(child)
return dict(title = title, text = lxml.html.tostring(html))
"""
"""
Return the content of a web page
......@@ -115,7 +65,6 @@ def urlread(url):
"""
def extractTest(text):
import lxml.html
from lxml import etree
root = lxml.html.fromstring(text)
table_list = root.xpath('//test')
testcode = ""
......@@ -132,10 +81,9 @@ def extractTest(text):
"""
HTML5 Presentation validador
"""
"""
def validateHTML5Document(text):
import lxml.html
from lxml import etree
root = lxml.html.fromstring(text)
section_list = root.xpath('//section')
count = 0
......@@ -148,17 +96,15 @@ def validateHTML5Document(text):
if section.get("class") in ["screenshot", "illustration"]:
if section.xpath("img") == []:
error_list.append("Section %s has class %s but it doesn't have any image." % (count, section.get("class")))
error_list.append("Section %s has class %s but it doesn't have any image." % (count, section.get("class")))
else:
if section.xpath("img")[0].get("title") == None:
error_list.append("At section %s, img has no title attribute." % count)
if section.xpath("img")[0].get("title") == None:
error_list.append("At section %s, img has no title attribute." % count)
if section.xpath("img")[0].get("alt") == None:
error_list.append("At section %s, img has no alt attribute." % count)
if section.xpath("img")[0].get("alt") == None:
error_list.append("At section %s, img has no alt attribute." % count)
if section.xpath("details") == []:
error_list.append("Section %s has no details tag." % (count))
return error_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Extension Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ERP5RunMyDocs</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.ERP5RunMyDocs</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Extension Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -80,53 +80,53 @@ class TestRunMyDoc(ERP5TypeTestCase):
reference=test_page_reference,
language="en",
version="001")
test_page.publish()
self.tic()
document = website.WebSection_getDocumentValue(test_page_reference)
self.assertNotEquals(None, document)
self.assertEqual(document.getRelativeUrl(),
test_page.getRelativeUrl())
def test_Zuite_uploadScreenShot(self):
"""
Test Screeshot upload script used by Zelenium to
Test Screeshot upload script used by Zelenium to
update screenshots of the documents.
"""
image_upload = makeFileUpload('TEST-en-002.png')
self.assertNotEquals(None, image_upload)
# Create a web page, and check if the content is not overwriten
web_page_reference = "WEB-PAGE-REFERENCE"
web_page = self.portal.web_page_module.newContent(
reference=web_page_reference,
reference=web_page_reference,
language="en", version="001")
web_page.publishAlive()
self.tic()
image_reference = "IMAGE-REFERENCE-%s" % str(time())
image_page = self.portal.image_module.newContent(
reference=image_reference,
reference=image_reference,
language="en", version="001")
image_page.publishAlive()
self.tic()
image_page_2 = self.portal.image_module.newContent(
reference=image_reference,
reference=image_reference,
language="en", version="002")
image_page_2.publishAlive()
self.tic()
self.portal.REQUEST.form['data_uri'] = image_upload
fake_image_reference = "DO-NOT-EXISTANT-IMAGE"
self.assertNotEquals(None,
self.assertNotEquals(None,
self.portal.Zuite_uploadScreenshot(image_upload, fake_image_reference))
self.assertNotEquals(None,
self.assertNotEquals(None,
self.portal.Zuite_uploadScreenshot(image_upload, web_page_reference))
self.assertEqual(None,
self.assertEqual(None,
self.portal.Zuite_uploadScreenshot(image_upload, image_reference))
self.tic()
......@@ -221,11 +221,11 @@ class TestRunMyDoc(ERP5TypeTestCase):
</table>
</body>
</html>"""
test_page = self.portal.test_page_module.newContent(title="TEST",
reference='TESTPAGEREFERENCE',
text_content=test_page_html)
self.assertEqual(test_page.TestPage_viewSeleniumTest(), expected_test_html %
self.assertEqual(test_page.TestPage_viewSeleniumTest(), expected_test_html %
("ERP5TypeTestCase", ""))
self.tic()
......@@ -233,7 +233,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
zuite = getattr(self.portal.portal_tests, 'TESTPAGEREFERENCE', None)
self.assertNotEquals(zuite, None)
zptest = getattr(zuite, "TEST", None)
self.assertNotEquals(zptest, None)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testRunMyDoc</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testRunMyDoc</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
ERP5RunMyDocs
\ No newline at end of file
extension.erp5.ERP5RunMyDocs
\ No newline at end of file
testRunMyDoc
\ No newline at end of file
test.erp5.testRunMyDoc
\ 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