Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d2128c4e
Commit
d2128c4e
authored
May 28, 2004
by
Paul Winkler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #596: bugfix and regression tests
parent
917c75ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
2 deletions
+81
-2
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+4
-1
lib/python/Products/PageTemplates/tests/__init__.py
lib/python/Products/PageTemplates/tests/__init__.py
+1
-1
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
...thon/Products/PageTemplates/tests/testZopePageTemplate.py
+76
-0
No files found.
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
d2128c4e
...
...
@@ -337,11 +337,14 @@ def manage_addPageTemplate(self, id, title=None, text=None,
file
=
REQUEST
.
form
.
get
(
'file'
)
headers
=
getattr
(
file
,
'headers'
,
None
)
if
headers
is
None
or
not
file
.
filename
:
zpt
=
ZopePageTemplate
(
id
)
zpt
=
ZopePageTemplate
(
id
,
text
)
else
:
zpt
=
ZopePageTemplate
(
id
,
file
,
headers
.
get
(
'content_type'
))
self
.
_setObject
(
id
,
zpt
)
if
title
:
ob
=
getattr
(
self
,
id
)
ob
.
pt_setTitle
(
title
)
try
:
u
=
self
.
DestinationURL
()
...
...
lib/python/Products/PageTemplates/tests/__init__.py
View file @
d2128c4e
def
all
():
import
testTALES
return
testTALES
.
test_suite
()
class
harness1
:
def
__init__
(
self
):
self
.
__callstack
=
[]
...
...
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
0 → 100644
View file @
d2128c4e
"""ZopePageTemplate regression tests.
Ensures that adding a page template works correctly.
Note: Tests require Zope >= 2.7
"""
import
unittest
from
Testing.makerequest
import
makerequest
class
DummyFileUpload
:
def
__init__
(
self
,
data
=
''
,
filename
=
''
,
content_type
=
''
):
self
.
data
=
data
self
.
filename
=
filename
self
.
headers
=
{
'content_type'
:
content_type
}
def
read
(
self
):
return
self
.
data
import
Zope
Zope
.
startup
()
class
ZPTRegressions
(
unittest
.
TestCase
):
def
setUp
(
self
):
get_transaction
().
begin
()
self
.
app
=
makerequest
(
Zope
.
app
())
f
=
self
.
app
.
manage_addProduct
[
'PageTemplates'
].
manage_addPageTemplate
self
.
_addPT
=
f
self
.
title
=
'title of page template'
self
.
text
=
'text of page template'
def
tearDown
(
self
):
get_transaction
().
abort
()
self
.
app
.
_p_jar
.
close
()
def
testAddWithParams
(
self
):
pt
=
self
.
_addPT
(
'pt1'
,
title
=
self
.
title
,
text
=
self
.
text
)
self
.
assertEqual
(
pt
.
title
,
self
.
title
)
self
.
assertEqual
(
pt
.
document_src
(),
self
.
text
)
def
testAddWithoutParams
(
self
):
pt
=
self
.
_addPT
(
'pt1'
)
default_text
=
open
(
pt
.
_default_content_fn
).
read
()
self
.
assertEqual
(
pt
.
title
,
''
)
self
.
assertEqual
(
pt
.
document_src
(),
default_text
)
def
testAddWithRequest
(
self
):
"""Test manage_add with file"""
request
=
self
.
app
.
REQUEST
request
.
form
[
'file'
]
=
DummyFileUpload
(
filename
=
'some file'
,
data
=
self
.
text
,
content_type
=
'text/html'
)
self
.
_addPT
(
'pt1'
,
REQUEST
=
request
)
# no object is returned when REQUEST is passed.
pt
=
self
.
app
.
pt1
self
.
assertEqual
(
pt
.
document_src
(),
self
.
text
)
def
testAddWithRequestButNoFile
(
self
):
"""Collector #596: manage_add with text but no file"""
request
=
self
.
app
.
REQUEST
self
.
_addPT
(
'pt1'
,
text
=
self
.
text
,
REQUEST
=
request
)
# no object is returned when REQUEST is passed.
pt
=
self
.
app
.
pt1
self
.
assertEqual
(
pt
.
document_src
(),
self
.
text
)
def
test_suite
():
return
unittest
.
makeSuite
(
ZPTRegressions
)
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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