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
Frederic Thoma
erp5
Commits
571299a3
Commit
571299a3
authored
Oct 01, 2019
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web: add Base_convertHtmlToSingleFile tests
parent
edebad63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
254 additions
and
1 deletion
+254
-1
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testWebPageConvert.py
...ateItem/portal_components/test.erp5.testWebPageConvert.py
+129
-0
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testWebPageConvert.xml
...teItem/portal_components/test.erp5.testWebPageConvert.xml
+123
-0
bt5/erp5_web/bt/template_test_id_list
bt5/erp5_web/bt/template_test_id_list
+2
-1
No files found.
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testWebPageConvert.py
0 → 100644
View file @
571299a3
##############################################################################
#
# Copyright (c) 2019 Nexedi SA and Contributors. All Rights Reserved.
#
# 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
class
TestWebPageConvert
(
ERP5TypeTestCase
):
def
getTitle
(
self
):
return
"Test Web Page Convert."
def
getBusinessTemplateList
(
self
):
return
(
"erp5_base"
,
"erp5_web"
,
"erp5_ui_test_core"
,
"erp5_ui_test"
,
"erp5_l10n_fr"
)
def
afterSetUp
(
self
):
base_web_page
=
self
.
portal
.
web_page_module
.
get
(
'Test_html_convert'
,
None
)
if
not
base_web_page
:
base_web_page
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
'Web Page'
,
id
=
'Test_html_convert'
)
self
.
base_url
=
base_web_page
.
getAbsoluteUrl
()
self
.
base_web_page
=
base_web_page
def
test_image_relative_src_convert
(
self
):
test_data
=
'<img alt="" src="./qr_screenshot?format=" title="" type="image/svg+xml" />'
expected_data
=
'<img alt="" src="%s/./qr_screenshot?format=" title="" type="image/svg+xml" />'
%
self
.
base_url
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_image_reference_src_convert
(
self
):
test_data
=
'<img alt="" src="reference" title="" type="image/svg+xml" />'
expected_data
=
'<img alt="" src="%s/reference" title="" type="image/svg+xml" />'
%
self
.
base_url
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_image_absolute_src_convert
(
self
):
test_data
=
'<img alt="" src="http://test" title="" type="image/svg+xml" />'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
test_data
)
def
test_image_empty_src_convert
(
self
):
#copy from Base_convertHtmlToSingleFile
test_data
=
'<img alt="" src="" title="" type="image/svg+xml" />'
expected_data
=
'<img alt="" src="data:text/html;base64," title="" type="image/svg+xml" />'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_a_relative_href_convert
(
self
):
test_data
=
'<a href="DesignDocument">Presentation</a>)'
expected_data
=
'<a href="%s/DesignDocument">Presentation</a>)'
%
self
.
base_url
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_a_absolute_href_convert
(
self
):
test_data
=
'<a href="http://DesignDocument">Presentation</a>)'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
test_data
)
def
test_a_empty_href_convert
(
self
):
test_data
=
'<a href="">Presentation</a>)'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
test_data
)
def
test_a_anchor_href_convert
(
self
):
test_data
=
'<a href="#DesignDocument">Presentation</a>)'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
test_data
)
def
test_script_inline_convert
(
self
):
test_data
=
'<!DOCTYPE html><html><head><script>console.log("test")</script></head></html>'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
,
allow_script
=
False
)
self
.
assertEqual
(
converted_data
,
'<!DOCTYPE html><html><head></head></html>'
)
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
,
allow_script
=
True
)
self
.
assertEqual
(
converted_data
,
test_data
)
def
test_script_external_convert
(
self
):
test_data
=
'<!DOCTYPE html><html><head><script src="erp5_xhtml_style/erp5.js"></script></head></html>'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
,
allow_script
=
True
)
expected_data
=
'<!DOCTYPE html><html><head><script src="%s/erp5_xhtml_style/erp5.js"></script></head></html>'
%
self
.
base_url
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_script_empty_convert
(
self
):
test_data
=
'<!DOCTYPE html><html><head><script src=""></script></head></html>'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
,
allow_script
=
True
)
expected_data
=
'<!DOCTYPE html><html><head><script src="data:text/html;base64,"></script></head></html>'
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_link_inline_convert
(
self
):
test_data
=
'<!DOCTYPE html><html><head><style>body{}</style></head></html>'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
self
.
assertEqual
(
converted_data
,
test_data
)
def
test_link_external_convert
(
self
):
test_data
=
'<!DOCTYPE html><html><head> <link rel="stylesheet" href="erp5_xhtml_style/erp5.css" /> </head></html>'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
expected_data
=
'<!DOCTYPE html><html><head> <link rel="stylesheet" href="%s/erp5_xhtml_style/erp5.css" /> </head></html>'
%
self
.
base_url
self
.
assertEqual
(
converted_data
,
expected_data
)
def
test_link_empty_convert
(
self
):
test_data
=
'<!DOCTYPE html><html><head> <link rel="stylesheet" href="" /> </head></html>'
converted_data
=
self
.
base_web_page
.
Base_convertHtmlToSingleFile
(
data
=
test_data
)
expected_data
=
'<!DOCTYPE html><html><head> <link rel="stylesheet" href="data:text/html;base64," /> </head></html>'
self
.
assertEqual
(
converted_data
,
expected_data
)
\ No newline at end of file
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testWebPageConvert.xml
0 → 100644
View file @
571299a3
<?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>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testWebPageConvert
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testWebPageConvert
</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"
>
AAAAAAAAAAM=
</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/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<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"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<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_web/bt/template_test_id_list
View file @
571299a3
test.erp5.testWebSiteLanguage
test.erp5.testWebSiteLanguage
\ No newline at end of file
test.erp5.testWebPageConvert
\ 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