Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
ZEO
Commits
39db61ba
Commit
39db61ba
authored
Jan 18, 2018
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coverage for 'ZEO.DB' convenience function.
parent
7c1eb8f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
14 deletions
+40
-14
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+40
-14
No files found.
src/ZEO/tests/testZEO.py
View file @
39db61ba
...
...
@@ -75,29 +75,55 @@ class CreativeGetState(persistent.Persistent):
return
super
(
CreativeGetState
,
self
).
__getstate__
()
class
DummyClientThread
(
object
):
def
__init__
(
self
,
*
args
,
**
kw
):
self
.
_args
=
args
self
.
_kw
=
kw
def
call
(
self
):
pass
def
async
(
self
):
pass
def
async_iter
(
self
):
pass
def
wait
(
self
):
pass
class
Test_convenience_functions
(
unittest
.
TestCase
):
def
test_ZEO_client_convenience
(
self
):
import
mock
import
ZEO
client_thread
=
mock
.
Mock
(
spec
=
[
'call'
,
'async'
,
'async_iter'
,
'wait'
])
client
=
ZEO
.
client
(
8001
,
wait
=
False
,
_client_factory
=
DummyClientT
hread
)
8001
,
wait
=
False
,
_client_factory
=
client_t
hread
)
self
.
assertIsInstance
(
client
,
ClientStorage
)
def
test_ZEO_DB_convenience_ok
(
self
):
import
mock
import
ZEO
client_mock
=
mock
.
Mock
(
spec
=
[
'close'
])
client_patch
=
mock
.
patch
(
'ZEO.client'
,
return_value
=
client_mock
)
DB_patch
=
mock
.
patch
(
'ZODB.DB'
)
dummy
=
object
()
with
client_patch
as
client
:
with
DB_patch
as
patched
:
db
=
ZEO
.
DB
(
dummy
)
self
.
assertIs
(
db
,
patched
())
client
.
assert_called_once_with
(
dummy
)
client_mock
.
close
.
assert_not_called
()
def
test_ZEO_DB_convenience_error
(
self
):
import
mock
import
ZEO
client_mock
=
mock
.
Mock
(
spec
=
[
'close'
])
client_patch
=
mock
.
patch
(
'ZEO.client'
,
return_value
=
client_mock
)
DB_patch
=
mock
.
patch
(
'ZODB.DB'
,
side_effect
=
ValueError
)
dummy
=
object
()
with
client_patch
as
client
:
with
DB_patch
:
with
self
.
assertRaises
(
ValueError
):
ZEO
.
DB
(
dummy
)
client
.
assert_called_once_with
(
dummy
)
client_mock
.
close
.
assert_called_once
()
class
MiscZEOTests
(
object
):
"""ZEO tests that don't fit in elsewhere."""
...
...
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