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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
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
Show 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>'
...
@@ -676,7 +662,7 @@ return True
...
@@ -676,7 +662,7 @@ return True
'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'
)
...
@@ -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>'
...
...
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