Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Kirill Smelkov
ZODB
Commits
6a667c11
Commit
6a667c11
authored
Feb 28, 2006
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for undo.
parent
46b0d1c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
src/ZODB/Blobs/tests/test_undo.py
src/ZODB/Blobs/tests/test_undo.py
+80
-0
No files found.
src/ZODB/Blobs/tests/test_undo.py
0 → 100644
View file @
6a667c11
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
unittest
import
tempfile
import
os
import
shutil
import
base64
from
ZODB.FileStorage
import
FileStorage
from
ZODB.Blobs.BlobStorage
import
BlobStorage
from
ZODB.Blobs.Blob
import
Blob
from
ZODB.DB
import
DB
import
transaction
from
ZODB.Blobs.Blob
import
Blob
class
BlobUndoTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
storagefile
=
tempfile
.
mktemp
()
self
.
blob_dir
=
tempfile
.
mkdtemp
()
def
tearDown
(
self
):
try
:
os
.
unlink
(
self
.
storagefile
)
except
(
OSError
,
IOError
):
pass
shutil
.
rmtree
(
self
.
blob_dir
)
def
testUndo
(
self
):
base_storage
=
FileStorage
(
self
.
storagefile
)
blob_storage
=
BlobStorage
(
self
.
blob_dir
,
base_storage
)
database
=
DB
(
blob_storage
)
connection
=
database
.
open
()
root
=
connection
.
root
()
transaction
.
begin
()
blob
=
Blob
()
blob
.
open
(
'w'
).
write
(
'this is state 1'
)
root
[
'blob'
]
=
blob
transaction
.
commit
()
transaction
.
begin
()
blob
=
root
[
'blob'
]
blob
.
open
(
'w'
).
write
(
'this is state 2'
)
transaction
.
commit
()
transaction
.
begin
()
blob
=
root
[
'blob'
]
self
.
assertEqual
(
blob
.
open
(
'r'
).
read
(),
'this is state 2'
)
transaction
.
abort
()
serial
=
base64
.
encodestring
(
blob_storage
.
_tid
)
transaction
.
begin
()
blob_storage
.
undo
(
serial
,
blob_storage
.
_transaction
)
transaction
.
commit
()
transaction
.
begin
()
blob
=
root
[
'blob'
]
self
.
assertEqual
(
blob
.
open
(
'r'
).
read
(),
'this is state 1'
)
transaction
.
abort
()
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
BlobUndoTests
))
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