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
Klaus Wölfel
erp5
Commits
394054e6
Commit
394054e6
authored
Jan 15, 2014
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup test thanks to pyflakes mostly
parent
5d37b37a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
37 deletions
+23
-37
product/ERP5/tests/testERP5WebWithDms.py
product/ERP5/tests/testERP5WebWithDms.py
+23
-37
No files found.
product/ERP5/tests/testERP5WebWithDms.py
View file @
394054e6
...
@@ -108,7 +108,6 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -108,7 +108,6 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
login
()
self
.
login
()
portal
=
self
.
getPortal
()
self
.
setDefaultSitePreference
()
self
.
setDefaultSitePreference
()
self
.
web_page_module
=
self
.
portal
.
web_page_module
self
.
web_page_module
=
self
.
portal
.
web_page_module
self
.
web_site_module
=
self
.
portal
.
web_site_module
self
.
web_site_module
=
self
.
portal
.
web_site_module
...
@@ -136,7 +135,6 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -136,7 +135,6 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
Setup Web Site
Setup Web Site
"""
"""
portal
=
self
.
getPortal
()
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
# add supported languages for Localizer
# add supported languages for Localizer
localizer
=
portal
.
Localizer
localizer
=
portal
.
Localizer
...
@@ -180,11 +178,6 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -180,11 +178,6 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
Setup some Web Pages.
Setup some Web Pages.
"""
"""
webpage_list
=
[]
webpage_list
=
[]
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
web_site_module
=
self
.
portal
.
getDefaultModule
(
'Web Site'
)
website
=
web_site_module
[
self
.
website_id
]
# create sample web pages
# create sample web pages
for
language
in
language_list
:
for
language
in
language_list
:
if
suffix
is
not
None
:
if
suffix
is
not
None
:
...
@@ -216,11 +209,10 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -216,11 +209,10 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
message
=
'
\
n
test_01_WebPageVersioning'
message
=
'
\
n
test_01_WebPageVersioning'
ZopeTestCase
.
_print
(
message
)
ZopeTestCase
.
_print
(
message
)
portal
=
self
.
getPortal
()
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
websection
=
self
.
setupWebSection
()
websection
=
self
.
setupWebSection
()
page_reference
=
'default-webpage-versionning'
page_reference
=
'default-webpage-versionning'
webpage_list
=
self
.
setupWebSitePages
(
prefix
=
page_reference
)
self
.
setupWebSitePages
(
prefix
=
page_reference
)
# set default web page for section
# set default web page for section
found_by_reference
=
portal
.
portal_catalog
(
reference
=
page_reference
,
found_by_reference
=
portal
.
portal_catalog
(
reference
=
page_reference
,
...
@@ -265,8 +257,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -265,8 +257,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
website
=
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
websection
=
self
.
setupWebSection
()
websection
=
self
.
setupWebSection
()
webpage_list
=
self
.
setupWebSitePages
(
prefix
=
'test-web-page'
)
self
.
setupWebSitePages
(
prefix
=
'test-web-page'
)
webpage
=
webpage_list
[
0
]
document_reference
=
'default-document-reference'
document_reference
=
'default-document-reference'
document
=
self
.
portal
.
web_page_module
.
newContent
(
document
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
'Web Page'
,
portal_type
=
'Web Page'
,
...
@@ -306,7 +297,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -306,7 +297,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
message
=
'
\
n
test_03_LatestContent'
message
=
'
\
n
test_03_LatestContent'
ZopeTestCase
.
_print
(
message
)
ZopeTestCase
.
_print
(
message
)
portal
=
self
.
getPortal
()
portal
=
self
.
getPortal
()
website
=
self
.
setupWebSite
()
self
.
setupWebSite
()
websection
=
self
.
setupWebSection
()
websection
=
self
.
setupWebSection
()
portal_categories
=
portal
.
portal_categories
portal_categories
=
portal
.
portal_categories
publication_section_category_id_list
=
[
'documentation'
,
'administration'
]
publication_section_category_id_list
=
[
'documentation'
,
'administration'
]
...
@@ -358,8 +349,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -358,8 +349,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
if
not
quiet
:
if
not
quiet
:
message
=
'
\
n
test_04_WebSectionAuthorizationForcedForDefaultDocument'
message
=
'
\
n
test_04_WebSectionAuthorizationForcedForDefaultDocument'
ZopeTestCase
.
_print
(
message
)
ZopeTestCase
.
_print
(
message
)
request
=
self
.
app
.
REQUEST
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
websection
=
self
.
setupWebSection
()
websection
=
self
.
setupWebSection
()
web_page_reference
=
'default-document-reference'
web_page_reference
=
'default-document-reference'
web_page_en
=
self
.
portal
.
web_page_module
.
newContent
(
web_page_en
=
self
.
portal
.
web_page_module
.
newContent
(
...
@@ -431,17 +421,15 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -431,17 +421,15 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
is correctly filled with getModificationDate of content.
is correctly filled with getModificationDate of content.
This test check "unauthenticated" Policy installed by erp5_web:
This test check "unauthenticated" Policy installed by erp5_web:
"""
"""
request
=
self
.
portal
.
REQUEST
website
=
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
path
=
website
.
absolute_url_path
()
website_url
=
website
.
absolute_url_path
()
response
=
self
.
publish
(
path
)
response
=
self
.
publish
(
website_url
)
self
.
assertTrue
(
response
.
getHeader
(
'x-cache-headers-set-by'
),
self
.
assertTrue
(
response
.
getHeader
(
'x-cache-headers-set-by'
),
'CachingPolicyManager: /erp5/caching_policy_manager'
)
'CachingPolicyManager: /erp5/caching_policy_manager'
)
web_section_portal_type
=
'Web Section'
web_section_portal_type
=
'Web Section'
web_section
=
website
.
newContent
(
portal_type
=
web_section_portal_type
)
web_section
=
website
.
newContent
(
portal_type
=
web_section_portal_type
)
path
=
web_section
.
absolute_url_path
()
response
=
self
.
publish
(
web_section
.
absolute_url_path
())
response
=
self
.
publish
(
path
)
self
.
assertTrue
(
response
.
getHeader
(
'x-cache-headers-set-by'
),
self
.
assertTrue
(
response
.
getHeader
(
'x-cache-headers-set-by'
),
'CachingPolicyManager: /erp5/caching_policy_manager'
)
'CachingPolicyManager: /erp5/caching_policy_manager'
)
...
@@ -452,8 +440,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -452,8 +440,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
reference
=
'NXD-Document-TEXT.Cache'
)
reference
=
'NXD-Document-TEXT.Cache'
)
document
.
publish
()
document
.
publish
()
self
.
tic
()
self
.
tic
()
path
=
website
.
absolute_url_path
()
+
'/NXD-Document-TEXT.Cache'
response
=
self
.
publish
(
website_url
+
'/NXD-Document-TEXT.Cache'
)
response
=
self
.
publish
(
path
)
last_modified_header
=
response
.
getHeader
(
'Last-Modified'
)
last_modified_header
=
response
.
getHeader
(
'Last-Modified'
)
self
.
assertTrue
(
last_modified_header
)
self
.
assertTrue
(
last_modified_header
)
from
App.Common
import
rfc1123_date
from
App.Common
import
rfc1123_date
...
@@ -469,21 +456,20 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -469,21 +456,20 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
document
.
edit
(
reference
=
reference
)
document
.
edit
(
reference
=
reference
)
document
.
publish
()
document
.
publish
()
self
.
tic
()
self
.
tic
()
website_url
=
website
.
absolute_url_path
()
# Check we can access to the 3 drawings converted into images.
# Check we can access to the 3 drawings converted into images.
# Those images can be accessible through extensible content
# Those images can be accessible through extensible content
# url : path-of-document + '/' + 'img' + page-index + '.png'
# url : path-of-document + '/' + 'img' + page-index + '.png'
for
i
in
range
(
3
):
policy_list
=
self
.
portal
.
caching_policy_manager
.
listPolicies
()
policy
=
[
policy
[
1
]
for
policy
in
policy_list
\
if
policy
[
0
]
==
'unauthenticated'
][
0
]
for
i
in
xrange
(
3
):
path
=
'/'
.
join
((
website_url
,
path
=
'/'
.
join
((
website_url
,
reference
,
reference
,
'img%s.png'
%
i
))
'img%s.png'
%
i
))
response
=
self
.
publish
(
path
)
response
=
self
.
publish
(
path
)
policy_list
=
self
.
portal
.
caching_policy_manager
.
listPolicies
()
policy
=
[
policy
for
policy
in
policy_list
\
if
policy
[
0
]
==
'unauthenticated'
][
0
]
self
.
assertEquals
(
response
.
getHeader
(
'Content-Type'
),
'image/png'
)
self
.
assertEquals
(
response
.
getHeader
(
'Content-Type'
),
'image/png'
)
self
.
assertEquals
(
response
.
getHeader
(
'Cache-Control'
),
self
.
assertEquals
(
response
.
getHeader
(
'Cache-Control'
),
'max-age=%s, public'
%
policy
[
1
]
.
getMaxAgeSecs
())
'max-age=%s, public'
%
policy
.
getMaxAgeSecs
())
def
test_07_TestDocumentViewBehaviour
(
self
):
def
test_07_TestDocumentViewBehaviour
(
self
):
"""All Documents shared the same downloading behaviour
"""All Documents shared the same downloading behaviour
...
@@ -499,7 +485,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -499,7 +485,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
request
[
'PARENTS'
]
=
[
self
.
app
]
request
[
'PARENTS'
]
=
[
self
.
app
]
website
=
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
web_section_portal_type
=
'Web Section'
web_section_portal_type
=
'Web Section'
web
_section
=
web
site
.
newContent
(
portal_type
=
web_section_portal_type
)
website
.
newContent
(
portal_type
=
web_section_portal_type
)
web_page_reference
=
'NXD-WEB-PAGE'
web_page_reference
=
'NXD-WEB-PAGE'
content
=
'<p>initial text</p>'
content
=
'<p>initial text</p>'
...
@@ -669,14 +655,14 @@ return True
...
@@ -669,14 +655,14 @@ return True
"""
"""
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
script_id
,
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
script_id
,
'format, **kw'
,
python_code
)
'format, **kw'
,
python_code
)
request
=
portal
.
REQUEST
request
=
portal
.
REQUEST
request
[
'PARENTS'
]
=
[
self
.
app
]
request
[
'PARENTS'
]
=
[
self
.
app
]
self
.
getPortalObject
().
aq_parent
.
acl_users
.
_doAddUser
(
self
.
getPortalObject
().
aq_parent
.
acl_users
.
_doAddUser
(
'zope_user'
,
''
,
[
'Manager'
,],
[])
'zope_user'
,
''
,
[
'Manager'
,],
[])
website
=
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
web_section_portal_type
=
'Web Section'
web_section_portal_type
=
'Web Section'
web
_section
=
web
site
.
newContent
(
portal_type
=
web_section_portal_type
)
website
.
newContent
(
portal_type
=
web_section_portal_type
)
document_reference
=
'tiolive-ERP5.Freedom.TioLive'
document_reference
=
'tiolive-ERP5.Freedom.TioLive'
upload_file
=
makeFileUpload
(
'tiolive-ERP5.Freedom.TioLive-001-en.odp'
)
upload_file
=
makeFileUpload
(
'tiolive-ERP5.Freedom.TioLive-001-en.odp'
)
...
@@ -740,7 +726,7 @@ return True
...
@@ -740,7 +726,7 @@ return True
self
.
assertTrue
(
response
.
getHeader
(
'content-type'
).
startswith
(
'text/html'
))
self
.
assertTrue
(
response
.
getHeader
(
'content-type'
).
startswith
(
'text/html'
))
html
=
response
.
getBody
()
html
=
response
.
getBody
()
self
.
assertTrue
(
'<img'
in
html
,
html
)
self
.
assertTrue
(
'<img'
in
html
,
html
)
# find the img src
# find the img src
img_list
=
etree
.
HTML
(
html
).
findall
(
'.//img'
)
img_list
=
etree
.
HTML
(
html
).
findall
(
'.//img'
)
self
.
assertEquals
(
1
,
len
(
img_list
))
self
.
assertEquals
(
1
,
len
(
img_list
))
...
@@ -751,7 +737,7 @@ return True
...
@@ -751,7 +737,7 @@ return True
are hounoured to display an image in context of a website
are hounoured to display an image in context of a website
"""
"""
self
.
test_ImageConversionThroughWebSite
(
"File"
)
self
.
test_ImageConversionThroughWebSite
(
"File"
)
def
test_ImageConversionThroughWebSite
(
self
,
image_portal_type
=
"Image"
):
def
test_ImageConversionThroughWebSite
(
self
,
image_portal_type
=
"Image"
):
"""Check that conversion parameters pass in url
"""Check that conversion parameters pass in url
are hounoured to display an image in context of a website
are hounoured to display an image in context of a website
...
@@ -761,7 +747,7 @@ return True
...
@@ -761,7 +747,7 @@ return True
request
[
'PARENTS'
]
=
[
self
.
app
]
request
[
'PARENTS'
]
=
[
self
.
app
]
website
=
self
.
setupWebSite
()
website
=
self
.
setupWebSite
()
web_section_portal_type
=
'Web Section'
web_section_portal_type
=
'Web Section'
web
_section
=
web
site
.
newContent
(
portal_type
=
web_section_portal_type
)
website
.
newContent
(
portal_type
=
web_section_portal_type
)
web_page_reference
=
'NXD-WEB-PAGE'
web_page_reference
=
'NXD-WEB-PAGE'
content
=
'<p>initial text</p>'
content
=
'<p>initial text</p>'
...
@@ -801,7 +787,7 @@ return True
...
@@ -801,7 +787,7 @@ return True
# testing Image conversions, svg
# testing Image conversions, svg
# disable Image permissiions checks format checks
# disable Image permissiions checks format checks
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
'Image_checkConversionFormatPermission'
,
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
'Image_checkConversionFormatPermission'
,
'**kw'
,
'return 1'
)
'**kw'
,
'return 1'
)
response
=
self
.
publish
(
website
.
absolute_url_path
()
+
'/'
+
\
response
=
self
.
publish
(
website
.
absolute_url_path
()
+
'/'
+
\
image_reference
+
'?format=svg'
,
credential
)
image_reference
+
'?format=svg'
,
credential
)
self
.
assertEquals
(
response
.
getHeader
(
'content-type'
),
'image/svg+xml'
)
self
.
assertEquals
(
response
.
getHeader
(
'content-type'
),
'image/svg+xml'
)
...
@@ -845,7 +831,7 @@ return True
...
@@ -845,7 +831,7 @@ return True
self
.
_test_document_publication_workflow
(
'Web Page'
,
self
.
_test_document_publication_workflow
(
'Web Page'
,
'share_alive_action'
)
'share_alive_action'
)
def
_testImageConversionFromSVGToPNG
(
self
,
portal_type
=
"Image"
,
def
_testImageConversionFromSVGToPNG
(
self
,
portal_type
=
"Image"
,
filename
=
"user-TESTSVG-CASE-EMBEDDEDDATA"
):
filename
=
"user-TESTSVG-CASE-EMBEDDEDDATA"
):
""" Test Convert one SVG Image (Image, TextDocument, File ...) to
""" Test Convert one SVG Image (Image, TextDocument, File ...) to
PNG and compare the generated image is well generated.
PNG and compare the generated image is well generated.
...
@@ -1002,7 +988,7 @@ return True
...
@@ -1002,7 +988,7 @@ return True
<image xlink:href="data:...." >
<image xlink:href="data:...." >
"""
"""
self
.
_testImageConversionFromSVGToPNG
(
"File"
)
self
.
_testImageConversionFromSVGToPNG
(
"File"
)
def
test_WebPageConversionFromSVGToPNG_embeeded_data
(
self
):
def
test_WebPageConversionFromSVGToPNG_embeeded_data
(
self
):
""" Test Convert one SVG Image with an image with the data
""" Test Convert one SVG Image with an image with the data
at the url of the image tag.ie:
at the url of the image tag.ie:
...
...
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