Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
erp5
Commits
a651b394
Commit
a651b394
authored
Jul 21, 2015
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XXX erp5_run_my_doc: Remove extension and test template
parent
9ef6a126
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
482 deletions
+0
-482
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
+0
-164
bt5/erp5_run_my_doc/TestTemplateItem/testRunMyDoc.py
bt5/erp5_run_my_doc/TestTemplateItem/testRunMyDoc.py
+0
-316
bt5/erp5_run_my_doc/bt/template_extension_id_list
bt5/erp5_run_my_doc/bt/template_extension_id_list
+0
-1
bt5/erp5_run_my_doc/bt/template_test_id_list
bt5/erp5_run_my_doc/bt/template_test_id_list
+0
-1
No files found.
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
deleted
100644 → 0
View file @
9ef6a126
"""
Parse the test report
"""
def
parseTestReport
(
text
):
from
lxml
import
etree
parser
=
etree
.
HTMLParser
(
remove_comments
=
True
)
parser
.
feed
(
text
)
root
=
parser
.
close
()
table
=
root
.
xpath
(
'//table[@id="SELENIUM-TEST"]'
)[
0
]
report
=
{}
header
=
table
[
0
][
0
]
report
[
'status'
]
=
header
.
attrib
[
'class'
].
find
(
'passed'
)
>
-
1
report
[
'name'
]
=
header
[
0
].
text
report
[
"row_list"
]
=
[]
report
[
"column_list"
]
=
[
0
,
0
,
0
]
i
=
0
for
row
in
table
[
1
]:
report
[
"row_list"
].
append
(
dict
(
cell_list
=
[],
passed
=
False
,
failed
=
False
,
done
=
False
,
not_done
=
False
))
row_report
=
report
[
"row_list"
][
i
]
if
row
.
attrib
[
'class'
].
find
(
'failed'
)
>
-
1
:
row_report
[
'failed'
]
=
True
elif
row
.
attrib
[
'class'
].
find
(
'done'
)
>
-
1
:
row_report
[
'done'
]
=
True
elif
row
.
attrib
[
'class'
].
find
(
'passed'
)
>
-
1
:
row_report
[
'passed'
]
=
True
else
:
row_report
[
'not_done'
]
=
True
for
column
in
row
:
row_report
[
"cell_list"
].
append
(
column
.
text
)
i
+=
1
return
report
"""
title = table.xpath('//td')[0].text
html[0][1].text = title
# Insert completly the first table
html[1].append(table)
# Insert only the content of tbody
for table in table_list[1:]:
for row in table[-1]:
html[1][-1].append(row)
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))
"""
"""
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
"""
def
urlread
(
url
):
import
urllib
return
urllib
.
urlopen
(
url
).
read
()
"""
Remove everything but the test in a webpage
"""
def
extractTest
(
text
):
import
lxml.html
from
lxml
import
etree
root
=
lxml
.
html
.
fromstring
(
text
)
table_list
=
root
.
xpath
(
'//test'
)
testcode
=
""
for
table
in
table_list
:
table
=
table
[
0
]
if
len
(
table
)
>
0
:
for
row
in
table
[
-
1
]:
if
len
(
row
)
==
1
:
# Include Macros as it is defined by the user.
testcode
+=
row
[
0
].
text
else
:
testcode
+=
lxml
.
html
.
tostring
(
row
)
return
testcode
"""
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
error_list
=
[]
# XXX Lack of translation support here.
for
section
in
section_list
:
count
+=
1
if
section
.
xpath
(
"h1"
)
==
[]:
error_list
.
append
(
"Section %s had no h1."
%
count
)
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"
)))
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
(
"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
bt5/erp5_run_my_doc/TestTemplateItem/testRunMyDoc.py
deleted
100644 → 0
View file @
9ef6a126
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5OOo.tests.testDms
import
makeFileUpload
from
time
import
time
class
TestRunMyDoc
(
ERP5TypeTestCase
):
"""
Basic Test for internal implementation of RunMyDocs
"""
def
getTitle
(
self
):
return
"Run My Doc"
def
getBusinessTemplateList
(
self
):
"""
Tuple of Business Templates we need to install
"""
return
(
'erp5_base'
,
'erp5_jquery'
,
'erp5_jquery_ui'
,
'erp5_knowledge_pad'
,
'erp5_ingestion_mysql_innodb_catalog'
,
'erp5_ingestion'
,
'erp5_web'
,
'erp5_dms'
,
'erp5_slideshow_style'
,
'erp5_ui_test_core'
,
'erp5_run_my_doc'
)
def
afterSetUp
(
self
):
"""
This is ran before anything, used to set the environment
"""
# here, you can create the categories and objects your test will depend on
website_id
=
"test_page_web_site"
def
test_getDocumentListWithTestPage
(
self
):
"""
Assert if Test Page works with getDocumentList
"""
test_page_reference
=
"developer-my.test.page"
website
=
getattr
(
self
.
portal
.
web_site_module
,
self
.
website_id
,
None
)
if
website
is
None
:
website
=
self
.
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
,
id
=
self
.
website_id
)
website
.
publish
()
self
.
tic
()
test_page
=
self
.
portal
.
test_page_module
.
newContent
(
portal_type
=
"Test Page"
,
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
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
,
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
,
language
=
"en"
,
version
=
"001"
)
image_page
.
publishAlive
()
self
.
tic
()
image_page_2
=
self
.
portal
.
image_module
.
newContent
(
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
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
fake_image_reference
))
self
.
assertNotEquals
(
None
,
self
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
web_page_reference
))
self
.
assertEqual
(
None
,
self
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
image_reference
))
self
.
tic
()
# The right image were updated.
image_upload
.
seek
(
0
)
self
.
assertEqual
(
image_page_2
.
getData
(),
image_upload
.
read
().
decode
(
"base64"
))
self
.
assertEqual
(
image_page_2
.
getFilename
(),
image_reference
+
'.png'
)
self
.
assertEqual
(
image_page
.
getData
(),
''
)
def
test_viewSeleniumTest
(
self
):
"""
Test the script that extracts Selenium Test from HTML body.
"""
test_page_html
=
"""<section><h1>TITLE</h1><details>DETAILS<details>
<test><table class="test" style="display: none;"> <tbody> </tbody></table> </test>
</section>
<section><h1>TITLE</h1><details>DETAILS<details><test>
<table class="test" style="display: none;">
<tbody>
<tr>
<td colspan="3"><span metal:use-macro="container/Zuite_viewTestMacroLibrary/macros/init_test_environment" style="display: none;">init</span></td>
</tr>
<tr>
<td>selectAndWait</td>
<td>name=select_module</td>
<td>label=Test Pages</td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Test Pages</td>
<td> <br /> </td>
</tr>
<tr style="opacity: 1;">
<td>clickAndWait</td>
<td>css=a.fast_input > span.image</td>
<td> <br /> </td>
</tr> </tbody></table> </test>
</section>
<section><h1>TITLE</h1><details>DETAILS<details><test>
<table class="test" style="display: none;"> <tbody>
<tr>
<td>verifyTextPresent</td>
<td>Test Pages</td>
<td> <br /> </td>
</tr> </tbody></table> </test>
</section>"""
expected_test_html
=
u"""<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TEST</title>
</head>
<body>
<table name="SELENIUM-TEST" cellpadding="1" cellspacing="1" border="1">
<thead>
<tr class="title">
<td colspan="3">TEST</td>
</tr>
</thead>
<tbody>
<span metal:use-macro="container/Zuite_CommonTemplate/macros/init" style="display: none;">init</span> <tr>
<td>store</td>
<!-- ERP5TypeTestCase is the default for any UnitTest -->
<td>%s</td>
<td>base_user</td>
</tr>
<tr>
<td>store</td>
<td>%s</td>
<td>base_password</td>
</tr>
<span metal:use-macro="container/Zuite_viewTestMacroLibrary/macros/init_test_environment" style="display: none;">init</span><tr>
<td>selectAndWait</td>
<td>name=select_module</td>
<td>label=Test Pages</td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Test Pages</td>
<td> <br> </td>
</tr>
<tr style="opacity: 1;">
<td>clickAndWait</td>
<td>css=a.fast_input > span.image</td>
<td> <br> </td>
</tr> <tr>
<td>verifyTextPresent</td>
<td>Test Pages</td>
<td> <br> </td>
</tr>
</tbody>
</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
%
(
"ERP5TypeTestCase"
,
""
))
self
.
tic
()
test_page
.
TestPage_runSeleniumTest
()
zuite
=
getattr
(
self
.
portal
.
portal_tests
,
'TESTPAGEREFERENCE'
,
None
)
self
.
assertNotEquals
(
zuite
,
None
)
zptest
=
getattr
(
zuite
,
"TEST"
,
None
)
self
.
assertNotEquals
(
zptest
,
None
)
expected_html
=
expected_test_html
%
(
"ERP5TypeTestCase"
,
""
)
self
.
assertEqual
(
zptest
.
_text
,
expected_html
.
strip
())
expected_test_html
=
u"""<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TEST</title>
</head>
<body>
<table name="SELENIUM-TEST" cellpadding="1" cellspacing="1" border="1">
<thead>
<tr class="title">
<td colspan="3">TEST</td>
</tr>
</thead>
<tbody>
<tr>
<td>store</td>
<td>%s</td>
<td>base_url</td>
</tr>
<tr>
<td>store</td>
<!-- ERP5TypeTestCase is the default for any UnitTest -->
<td>%s</td>
<td>base_user</td>
</tr>
<tr>
<td>store</td>
<td>%s</td>
<td>base_password</td>
</tr>
<span metal:use-macro="container/Zuite_viewTestMacroLibrary/macros/init_test_environment" style="display: none;">init</span><tr>
<td>selectAndWait</td>
<td>name=select_module</td>
<td>label=Test Pages</td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Test Pages</td>
<td> <br> </td>
</tr>
<tr style="opacity: 1;">
<td>clickAndWait</td>
<td>css=a.fast_input > span.image</td>
<td> <br> </td>
</tr> <tr>
<td>verifyTextPresent</td>
<td>Test Pages</td>
<td> <br> </td>
</tr>
</tbody>
</table>
</body>
</html>"""
# Mimic usage of TestPage_viewSeleniumTest?url=...
self
.
portal
.
REQUEST
[
'url'
]
=
"http://toto.com"
self
.
portal
.
REQUEST
[
'user'
]
=
"toto"
self
.
portal
.
REQUEST
[
'password'
]
=
"toto"
self
.
assertEqual
(
test_page
.
TestPage_viewSeleniumTest
(
REQUEST
=
self
.
portal
.
REQUEST
),
expected_test_html
%
(
"http://toto.com"
,
"toto"
,
"toto"
))
self
.
tic
()
test_page
.
TestPage_runSeleniumTest
()
zuite
=
getattr
(
self
.
portal
.
portal_tests
,
'TESTPAGEREFERENCE'
,
None
)
self
.
assertNotEquals
(
zuite
,
None
)
zptest
=
getattr
(
zuite
,
"TEST"
,
None
)
self
.
assertNotEquals
(
zptest
,
None
)
expected_html
=
expected_test_html
%
(
"http://toto.com"
,
"toto"
,
"toto"
)
self
.
assertEqual
(
zptest
.
_text
,
expected_html
.
strip
())
bt5/erp5_run_my_doc/bt/template_extension_id_list
deleted
100644 → 0
View file @
9ef6a126
ERP5RunMyDocs
\ No newline at end of file
bt5/erp5_run_my_doc/bt/template_test_id_list
deleted
100644 → 0
View file @
9ef6a126
testRunMyDoc
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment