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
4f61c1c7
Commit
4f61c1c7
authored
Jul 10, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a simple stub class instead of a PythonScripts to test OFS.Historical
parent
65ef4d4f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
src/OFS/tests/testHistory.py
src/OFS/tests/testHistory.py
+28
-24
No files found.
src/OFS/tests/testHistory.py
View file @
4f61c1c7
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
...
...
@@ -9,37 +8,45 @@ import transaction
import
tempfile
import
ZODB
from
OFS.Application
import
Application
from
Products.PythonScripts.PythonScript
import
manage_addPythonScript
from
OFS.History
import
Historical
from
OFS.SimpleItem
import
SimpleItem
from
ZODB.FileStorage
import
FileStorage
class
HistoryItem
(
SimpleItem
,
Historical
):
pass
class
HistoryTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# set up a zodb
# we can't use DemoStorage here 'cos it doesn't support History
self
.
dir
=
tempfile
.
mkdtemp
()
self
.
s
=
FileStorage
(
os
.
path
.
join
(
self
.
dir
,
'testHistory.fs'
),
create
=
True
)
fs_path
=
os
.
path
.
join
(
self
.
dir
,
'testHistory.fs'
)
self
.
s
=
FileStorage
(
fs_path
,
create
=
True
)
self
.
connection
=
ZODB
.
DB
(
self
.
s
).
open
()
r
=
self
.
connection
.
root
()
a
=
Application
()
r
[
'Application'
]
=
a
self
.
root
=
a
# create a python script
manage_addPythonScript
(
a
,
'test'
)
self
.
ps
=
ps
=
a
.
test
a
[
'test'
]
=
HistoryItem
(
)
self
.
hi
=
hi
=
a
.
test
# commit some changes
ps
.
write
(
'return 1'
)
hi
.
title
=
'First title'
t
=
transaction
.
get
()
# undo note made by Application instantiation above.
t
.
description
=
None
t
.
note
(
'Change 1'
)
t
.
commit
()
ps
.
write
(
'return 2'
)
hi
.
title
=
'Second title'
t
=
transaction
.
get
()
t
.
note
(
'Change 2'
)
t
.
commit
()
ps
.
write
(
'return 3'
)
hi
.
title
=
'Third title'
t
=
transaction
.
get
()
t
.
note
(
'Change 3'
)
t
.
commit
()
...
...
@@ -55,7 +62,7 @@ class HistoryTests(unittest.TestCase):
shutil
.
rmtree
(
self
.
dir
)
def
test_manage_change_history
(
self
):
r
=
self
.
ps
.
manage_change_history
()
r
=
self
.
hi
.
manage_change_history
()
self
.
assertEqual
(
len
(
r
),
3
)
# three transactions
for
i
in
range
(
3
):
entry
=
r
[
i
]
...
...
@@ -75,22 +82,19 @@ class HistoryTests(unittest.TestCase):
def
test_manage_historyCopy
(
self
):
# we assume this works 'cos it's tested above
r
=
self
.
ps
.
manage_change_history
()
r
=
self
.
hi
.
manage_change_history
()
# now we do the copy
self
.
ps
.
manage_historyCopy
(
self
.
hi
.
manage_historyCopy
(
keys
=
[
r
[
2
][
'key'
]]
)
# do a commit, just like ZPublisher would
transaction
.
commit
()
# check the body is as it should be, we assume (hopefully not foolishly)
# that all other attributes will behave the same
self
.
assertEqual
(
self
.
ps
.
_body
,
'
return 1
\
n
'
)
self
.
assertEqual
(
self
.
hi
.
title
,
'
First title
'
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
HistoryTests
)
)
suite
.
addTest
(
unittest
.
makeSuite
(
HistoryTests
)
)
return
suite
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