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
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
Nicolas Wavrant
ZODB
Commits
9cfba5ed
Commit
9cfba5ed
authored
Nov 18, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check in test I missed checking in yesterday
sigh
parent
7396ca0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
+95
-0
src/ZODB/tests/test_TransactionMetaData.py
src/ZODB/tests/test_TransactionMetaData.py
+95
-0
No files found.
src/ZODB/tests/test_TransactionMetaData.py
0 → 100644
View file @
9cfba5ed
##############################################################################
#
# Copyright (c) Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
warnings
from
.._compat
import
dumps
,
loads
,
_protocol
from
..Connection
import
TransactionMetaData
class
TransactionMetaDataTests
(
unittest
.
TestCase
):
def
test_basic
(
self
):
t
=
TransactionMetaData
(
u'user
\
x80
'
,
u'description
\
x80
'
,
dict
(
foo
=
'FOO'
))
self
.
assertEqual
(
t
.
user
,
b'user
\
xc2
\
x80
'
)
self
.
assertEqual
(
t
.
description
,
b'description
\
xc2
\
x80
'
)
self
.
assertEqual
(
t
.
extension
,
dict
(
foo
=
'FOO'
))
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
self
.
assertEqual
(
t
.
_extension
,
t
.
extension
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertTrue
(
issubclass
(
w
[
-
1
].
category
,
DeprecationWarning
))
self
.
assertTrue
(
"_extension is deprecated"
in
str
(
w
[
-
1
].
message
))
def
test_basic_no_encoding
(
self
):
t
=
TransactionMetaData
(
b'user'
,
b'description'
,
dumps
(
dict
(
foo
=
'FOO'
),
_protocol
))
self
.
assertEqual
(
t
.
user
,
b'user'
)
self
.
assertEqual
(
t
.
description
,
b'description'
)
self
.
assertEqual
(
t
.
extension
,
dict
(
foo
=
'FOO'
))
self
.
assertEqual
(
t
.
_extension
,
t
.
extension
)
def
test_constructor_default_args
(
self
):
t
=
TransactionMetaData
()
self
.
assertEqual
(
t
.
user
,
b''
)
self
.
assertEqual
(
t
.
description
,
b''
)
self
.
assertEqual
(
t
.
extension
,
{})
self
.
assertEqual
(
t
.
_extension
,
t
.
extension
)
def
test_set_extension
(
self
):
t
=
TransactionMetaData
(
u''
,
u''
,
b''
)
self
.
assertEqual
(
t
.
user
,
b''
)
self
.
assertEqual
(
t
.
description
,
b''
)
self
.
assertEqual
(
t
.
extension
,
{})
self
.
assertEqual
(
t
.
_extension
,
t
.
extension
)
for
name
in
'extension'
,
'_extension'
:
data
=
{
name
:
name
+
'foo'
}
setattr
(
t
,
name
,
data
)
self
.
assertEqual
(
t
.
extension
,
data
)
self
.
assertEqual
(
t
.
_extension
,
t
.
extension
)
data
=
{}
setattr
(
t
,
name
,
data
)
self
.
assertEqual
(
t
.
extension
,
data
)
self
.
assertEqual
(
t
.
_extension
,
t
.
extension
)
def
test_used_by_connection
(
self
):
import
ZODB
from
ZODB.MappingStorage
import
MappingStorage
class
Storage
(
MappingStorage
):
def
tpc_begin
(
self
,
transaction
):
self
.
test_transaction
=
transaction
return
MappingStorage
.
tpc_begin
(
self
,
transaction
)
storage
=
Storage
()
conn
=
ZODB
.
connection
(
storage
)
with
conn
.
transaction_manager
as
t
:
t
.
user
=
u'user
\
x80
'
t
.
description
=
u'description
\
x80
'
t
.
setExtendedInfo
(
'foo'
,
'FOO'
)
conn
.
root
.
x
=
1
t
=
storage
.
test_transaction
self
.
assertEqual
(
t
.
__class__
,
TransactionMetaData
)
self
.
assertEqual
(
t
.
user
,
b'user
\
xc2
\
x80
'
)
self
.
assertEqual
(
t
.
description
,
b'description
\
xc2
\
x80
'
)
self
.
assertEqual
(
t
.
extension
,
dict
(
foo
=
'FOO'
))
def
test_suite
():
return
unittest
.
makeSuite
(
TransactionMetaDataTests
)
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