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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
bc184f63
Commit
bc184f63
authored
Jan 18, 2018
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coverage for 'ZEO.connection' convenience function.
Closes #102.
parent
39db61ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
src/ZEO/__init__.py
src/ZEO/__init__.py
+1
-1
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+38
-0
No files found.
src/ZEO/__init__.py
View file @
bc184f63
...
...
@@ -40,7 +40,7 @@ def connection(*args, **kw):
return
db
.
open_then_close_db_when_connection_closes
()
except
Exception
:
db
.
close
()
ra
ra
ise
def
server
(
path
=
None
,
blob_dir
=
None
,
storage_conf
=
None
,
zeo_conf
=
None
,
port
=
0
,
threaded
=
True
,
**
kw
):
...
...
src/ZEO/tests/testZEO.py
View file @
bc184f63
...
...
@@ -124,6 +124,44 @@ class Test_convenience_functions(unittest.TestCase):
client
.
assert_called_once_with
(
dummy
)
client_mock
.
close
.
assert_called_once
()
def
test_ZEO_connection_convenience_ok
(
self
):
import
mock
import
ZEO
ret
=
object
()
DB_mock
=
mock
.
Mock
(
spec
=
[
'close'
,
'open_then_close_db_when_connection_closes'
])
DB_mock
.
open_then_close_db_when_connection_closes
.
return_value
=
ret
DB_patch
=
mock
.
patch
(
'ZEO.DB'
,
return_value
=
DB_mock
)
dummy
=
object
()
with
DB_patch
as
patched
:
conn
=
ZEO
.
connection
(
dummy
)
self
.
assertIs
(
conn
,
ret
)
patched
.
assert_called_once_with
(
dummy
)
DB_mock
.
close
.
assert_not_called
()
def
test_ZEO_connection_convenience_value
(
self
):
import
mock
import
ZEO
DB_mock
=
mock
.
Mock
(
spec
=
[
'close'
,
'open_then_close_db_when_connection_closes'
])
otc
=
DB_mock
.
open_then_close_db_when_connection_closes
otc
.
side_effect
=
ValueError
DB_patch
=
mock
.
patch
(
'ZEO.DB'
,
return_value
=
DB_mock
)
dummy
=
object
()
with
DB_patch
as
patched
:
with
self
.
assertRaises
(
ValueError
):
ZEO
.
connection
(
dummy
)
patched
.
assert_called_once_with
(
dummy
)
DB_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