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
ee321f09
Commit
ee321f09
authored
May 01, 2006
by
Chris Withers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #2062: Fix manage_historyCopy, which was broken, and write tests for it.
parent
16e6b975
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
7 deletions
+104
-7
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/OFS/History.py
lib/python/OFS/History.py
+4
-7
lib/python/OFS/tests/testHistory.py
lib/python/OFS/tests/testHistory.py
+97
-0
No files found.
doc/CHANGES.txt
View file @
ee321f09
...
...
@@ -18,6 +18,9 @@ Zope Changes
Bugs fixed
- Collector #2062: Fix manage_historyCopy, which was broken, and write
tests for it.
- Collector #2061: Fix problems where windows line endings are passed
to restricted code compilers.
...
...
lib/python/OFS/History.py
View file @
ee321f09
...
...
@@ -144,15 +144,12 @@ class Historical(ExtensionClass.Base):
if
serial
!=
self
.
_p_serial
:
self
.
manage_beforeHistoryCopy
()
state
=
self
.
_p_jar
.
oldstate
(
self
,
serial
)
# Scrub the object before restoring the old state
base
=
aq_base
(
self
)
base
.
_p_changed
=
0
base
.
_p_deactivate
()
base
.
__setstate__
(
state
)
base
.
_p_changed
=
1
base
.
_p_activate
()
# make sure we're not a ghost
base
.
__setstate__
(
state
)
# change the state
base
.
_p_changed
=
True
# marke object as dirty
self
.
manage_afterHistoryCopy
()
if
RESPONSE
is
not
None
and
URL1
is
not
None
:
RESPONSE
.
redirect
(
URL1
+
'/manage_workspace'
)
...
...
lib/python/OFS/tests/testHistory.py
0 → 100644
View file @
ee321f09
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
import
os
import
shutil
import
transaction
import
tempfile
import
ZODB
from
OFS.Application
import
Application
from
Products.PythonScripts.PythonScript
import
manage_addPythonScript
from
ZODB.FileStorage
import
FileStorage
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
)
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
# commit some changes
ps
.
write
(
'return 1'
)
t
=
transaction
.
get
()
# undo note made by Application instantiation above.
t
.
description
=
None
t
.
note
(
'Change 1'
)
t
.
commit
()
ps
.
write
(
'return 2'
)
t
=
transaction
.
get
()
t
.
note
(
'Change 2'
)
t
.
commit
()
ps
.
write
(
'return 3'
)
t
=
transaction
.
get
()
t
.
note
(
'Change 3'
)
t
.
commit
()
def
tearDown
(
self
):
# get rid of ZODB
transaction
.
abort
()
self
.
connection
.
close
()
self
.
s
.
close
()
del
self
.
root
del
self
.
connection
del
self
.
s
shutil
.
rmtree
(
self
.
dir
)
def
test_manage_change_history
(
self
):
r
=
self
.
ps
.
manage_change_history
()
self
.
assertEqual
(
len
(
r
),
3
)
# three transactions
for
i
in
range
(
3
):
entry
=
r
[
i
]
# check no new keys show up without testing
self
.
assertEqual
(
len
(
entry
.
keys
()),
7
)
# the transactions are in newest-first order
self
.
assertEqual
(
entry
[
'description'
],
'Change %i'
%
(
3
-
i
))
self
.
failUnless
(
'key'
in
entry
)
# lets not assume the size will stay the same forever
self
.
failUnless
(
'size'
in
entry
)
self
.
failUnless
(
'tid'
in
entry
)
self
.
failUnless
(
'time'
in
entry
)
if
i
:
# check times are increasing
self
.
failUnless
(
entry
[
'time'
]
<
r
[
i
-
1
][
'time'
])
self
.
assertEqual
(
entry
[
'user_name'
],
''
)
self
.
assertEqual
(
entry
[
'version'
],
''
)
def
test_manage_historyCopy
(
self
):
# we assume this works 'cos it's tested above
r
=
self
.
ps
.
manage_change_history
()
# now we do the copy
self
.
ps
.
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
'
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
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