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
alecs_myu
erp5
Commits
d5564ccf
Commit
d5564ccf
authored
Jan 11, 2016
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_run_my_doc: move extension and test to portal_components
Also remove unused broken function
parent
44380d16
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
228 additions
and
78 deletions
+228
-78
bt5/erp5_run_my_doc/ExtensionTemplateItem/portal_components/extension.erp5.ERP5RunMyDocs.py
...ateItem/portal_components/extension.erp5.ERP5RunMyDocs.py
+8
-62
bt5/erp5_run_my_doc/ExtensionTemplateItem/portal_components/extension.erp5.ERP5RunMyDocs.xml
...teItem/portal_components/extension.erp5.ERP5RunMyDocs.xml
+102
-0
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.py
...tTemplateItem/portal_components/test.erp5.testRunMyDoc.py
+14
-14
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.xml
...TemplateItem/portal_components/test.erp5.testRunMyDoc.xml
+102
-0
bt5/erp5_run_my_doc/bt/template_extension_id_list
bt5/erp5_run_my_doc/bt/template_extension_id_list
+1
-1
bt5/erp5_run_my_doc/bt/template_test_id_list
bt5/erp5_run_my_doc/bt/template_test_id_list
+1
-1
No files found.
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
→
bt5/erp5_run_my_doc/ExtensionTemplateItem/
portal_components/extension.erp5.
ERP5RunMyDocs.py
View file @
d5564ccf
...
@@ -7,7 +7,7 @@ def parseTestReport(text):
...
@@ -7,7 +7,7 @@ def parseTestReport(text):
parser
.
feed
(
text
)
parser
.
feed
(
text
)
root
=
parser
.
close
()
root
=
parser
.
close
()
table
=
root
.
xpath
(
'//table[@id="SELENIUM-TEST"]'
)[
0
]
table
=
root
.
xpath
(
'//table[@id="SELENIUM-TEST"]'
)[
0
]
report
=
{}
report
=
dict
()
header
=
table
[
0
][
0
]
header
=
table
[
0
][
0
]
report
[
'status'
]
=
header
.
attrib
[
'class'
].
find
(
'passed'
)
>
-
1
report
[
'status'
]
=
header
.
attrib
[
'class'
].
find
(
'passed'
)
>
-
1
report
[
'name'
]
=
header
[
0
].
text
report
[
'name'
]
=
header
[
0
].
text
...
@@ -49,59 +49,9 @@ def parseTestReport(text):
...
@@ -49,59 +49,9 @@ def parseTestReport(text):
del element.attrib['style']
del element.attrib['style']
for child in element:
for child in element:
stack.append(child)
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 dict(title = title, text = lxml.html.tostring(html))
"""
"""
"""
Return the content of a web page
Return the content of a web page
...
@@ -115,7 +65,6 @@ def urlread(url):
...
@@ -115,7 +65,6 @@ def urlread(url):
"""
"""
def
extractTest
(
text
):
def
extractTest
(
text
):
import
lxml.html
import
lxml.html
from
lxml
import
etree
root
=
lxml
.
html
.
fromstring
(
text
)
root
=
lxml
.
html
.
fromstring
(
text
)
table_list
=
root
.
xpath
(
'//test'
)
table_list
=
root
.
xpath
(
'//test'
)
testcode
=
""
testcode
=
""
...
@@ -132,10 +81,9 @@ def extractTest(text):
...
@@ -132,10 +81,9 @@ def extractTest(text):
"""
"""
HTML5 Presentation validador
HTML5 Presentation validador
"""
"""
def
validateHTML5Document
(
text
):
def
validateHTML5Document
(
text
):
import
lxml.html
import
lxml.html
from
lxml
import
etree
root
=
lxml
.
html
.
fromstring
(
text
)
root
=
lxml
.
html
.
fromstring
(
text
)
section_list
=
root
.
xpath
(
'//section'
)
section_list
=
root
.
xpath
(
'//section'
)
count
=
0
count
=
0
...
@@ -148,17 +96,15 @@ def validateHTML5Document(text):
...
@@ -148,17 +96,15 @@ def validateHTML5Document(text):
if
section
.
get
(
"class"
)
in
[
"screenshot"
,
"illustration"
]:
if
section
.
get
(
"class"
)
in
[
"screenshot"
,
"illustration"
]:
if
section
.
xpath
(
"img"
)
==
[]:
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
:
else
:
if
section
.
xpath
(
"img"
)[
0
].
get
(
"title"
)
==
None
:
if
section
.
xpath
(
"img"
)[
0
].
get
(
"title"
)
==
None
:
error_list
.
append
(
"At section %s, img has no title attribute."
%
count
)
error_list
.
append
(
"At section %s, img has no title attribute."
%
count
)
if
section
.
xpath
(
"img"
)[
0
].
get
(
"alt"
)
==
None
:
if
section
.
xpath
(
"img"
)[
0
].
get
(
"alt"
)
==
None
:
error_list
.
append
(
"At section %s, img has no alt attribute."
%
count
)
error_list
.
append
(
"At section %s, img has no alt attribute."
%
count
)
if
section
.
xpath
(
"details"
)
==
[]:
if
section
.
xpath
(
"details"
)
==
[]:
error_list
.
append
(
"Section %s has no details tag."
%
(
count
))
error_list
.
append
(
"Section %s has no details tag."
%
(
count
))
return
error_list
return
error_list
bt5/erp5_run_my_doc/ExtensionTemplateItem/portal_components/extension.erp5.ERP5RunMyDocs.xml
0 → 100644
View file @
d5564ccf
<?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>
bt5/erp5_run_my_doc/TestTemplateItem/testRunMyDoc.py
→
bt5/erp5_run_my_doc/TestTemplateItem/
portal_components/test.erp5.
testRunMyDoc.py
View file @
d5564ccf
...
@@ -80,53 +80,53 @@ class TestRunMyDoc(ERP5TypeTestCase):
...
@@ -80,53 +80,53 @@ class TestRunMyDoc(ERP5TypeTestCase):
reference
=
test_page_reference
,
reference
=
test_page_reference
,
language
=
"en"
,
language
=
"en"
,
version
=
"001"
)
version
=
"001"
)
test_page
.
publish
()
test_page
.
publish
()
self
.
tic
()
self
.
tic
()
document
=
website
.
WebSection_getDocumentValue
(
test_page_reference
)
document
=
website
.
WebSection_getDocumentValue
(
test_page_reference
)
self
.
assertNotEquals
(
None
,
document
)
self
.
assertNotEquals
(
None
,
document
)
self
.
assertEqual
(
document
.
getRelativeUrl
(),
self
.
assertEqual
(
document
.
getRelativeUrl
(),
test_page
.
getRelativeUrl
())
test_page
.
getRelativeUrl
())
def
test_Zuite_uploadScreenShot
(
self
):
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.
update screenshots of the documents.
"""
"""
image_upload
=
makeFileUpload
(
'TEST-en-002.png'
)
image_upload
=
makeFileUpload
(
'TEST-en-002.png'
)
self
.
assertNotEquals
(
None
,
image_upload
)
self
.
assertNotEquals
(
None
,
image_upload
)
# Create a web page, and check if the content is not overwriten
# Create a web page, and check if the content is not overwriten
web_page_reference
=
"WEB-PAGE-REFERENCE"
web_page_reference
=
"WEB-PAGE-REFERENCE"
web_page
=
self
.
portal
.
web_page_module
.
newContent
(
web_page
=
self
.
portal
.
web_page_module
.
newContent
(
reference
=
web_page_reference
,
reference
=
web_page_reference
,
language
=
"en"
,
version
=
"001"
)
language
=
"en"
,
version
=
"001"
)
web_page
.
publishAlive
()
web_page
.
publishAlive
()
self
.
tic
()
self
.
tic
()
image_reference
=
"IMAGE-REFERENCE-%s"
%
str
(
time
())
image_reference
=
"IMAGE-REFERENCE-%s"
%
str
(
time
())
image_page
=
self
.
portal
.
image_module
.
newContent
(
image_page
=
self
.
portal
.
image_module
.
newContent
(
reference
=
image_reference
,
reference
=
image_reference
,
language
=
"en"
,
version
=
"001"
)
language
=
"en"
,
version
=
"001"
)
image_page
.
publishAlive
()
image_page
.
publishAlive
()
self
.
tic
()
self
.
tic
()
image_page_2
=
self
.
portal
.
image_module
.
newContent
(
image_page_2
=
self
.
portal
.
image_module
.
newContent
(
reference
=
image_reference
,
reference
=
image_reference
,
language
=
"en"
,
version
=
"002"
)
language
=
"en"
,
version
=
"002"
)
image_page_2
.
publishAlive
()
image_page_2
.
publishAlive
()
self
.
tic
()
self
.
tic
()
self
.
portal
.
REQUEST
.
form
[
'data_uri'
]
=
image_upload
self
.
portal
.
REQUEST
.
form
[
'data_uri'
]
=
image_upload
fake_image_reference
=
"DO-NOT-EXISTANT-IMAGE"
fake_image_reference
=
"DO-NOT-EXISTANT-IMAGE"
self
.
assertNotEquals
(
None
,
self
.
assertNotEquals
(
None
,
self
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
fake_image_reference
))
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
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
web_page_reference
))
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
self
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
image_reference
))
self
.
portal
.
Zuite_uploadScreenshot
(
image_upload
,
image_reference
))
self
.
tic
()
self
.
tic
()
...
@@ -221,11 +221,11 @@ class TestRunMyDoc(ERP5TypeTestCase):
...
@@ -221,11 +221,11 @@ class TestRunMyDoc(ERP5TypeTestCase):
</table>
</table>
</body>
</body>
</html>"""
</html>"""
test_page
=
self
.
portal
.
test_page_module
.
newContent
(
title
=
"TEST"
,
test_page
=
self
.
portal
.
test_page_module
.
newContent
(
title
=
"TEST"
,
reference
=
'TESTPAGEREFERENCE'
,
reference
=
'TESTPAGEREFERENCE'
,
text_content
=
test_page_html
)
text_content
=
test_page_html
)
self
.
assertEqual
(
test_page
.
TestPage_viewSeleniumTest
(),
expected_test_html
%
self
.
assertEqual
(
test_page
.
TestPage_viewSeleniumTest
(),
expected_test_html
%
(
"ERP5TypeTestCase"
,
""
))
(
"ERP5TypeTestCase"
,
""
))
self
.
tic
()
self
.
tic
()
...
@@ -233,7 +233,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
...
@@ -233,7 +233,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
zuite
=
getattr
(
self
.
portal
.
portal_tests
,
'TESTPAGEREFERENCE'
,
None
)
zuite
=
getattr
(
self
.
portal
.
portal_tests
,
'TESTPAGEREFERENCE'
,
None
)
self
.
assertNotEquals
(
zuite
,
None
)
self
.
assertNotEquals
(
zuite
,
None
)
zptest
=
getattr
(
zuite
,
"TEST"
,
None
)
zptest
=
getattr
(
zuite
,
"TEST"
,
None
)
self
.
assertNotEquals
(
zptest
,
None
)
self
.
assertNotEquals
(
zptest
,
None
)
...
...
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.xml
0 → 100644
View file @
d5564ccf
<?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>
bt5/erp5_run_my_doc/bt/template_extension_id_list
View file @
d5564ccf
ERP5RunMyDocs
extension.erp5.ERP5RunMyDocs
\ No newline at end of file
\ No newline at end of file
bt5/erp5_run_my_doc/bt/template_test_id_list
View file @
d5564ccf
testRunMyDoc
test.erp5.testRunMyDoc
\ No newline at end of file
\ 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