Commit 721181c9 authored by Tres Seaver's avatar Tres Seaver Committed by GitHub

Merge pull request #8 from tkoym/master

Add missing ClientStorage constructor kw args to resolver.
parents 081e1ef8 60da0196
...@@ -100,3 +100,4 @@ Contributors ...@@ -100,3 +100,4 @@ Contributors
- Georges Dubus, 2012/05/27 - Georges Dubus, 2012/05/27
- Tres Seaver, 2012/05/27 - Tres Seaver, 2012/05/27
- Steve Piercy, 2016/07/21 - Steve Piercy, 2016/07/21
- Todd Koym, 2016/07/21
...@@ -159,6 +159,8 @@ min_disconnect_poll ...@@ -159,6 +159,8 @@ min_disconnect_poll
integer integer
max_disconnect_poll max_disconnect_poll
integer integer
wait_for_server_on_startup (deprecated alias for wait)
boolean
wait wait
boolean boolean
wait_timeout wait_timeout
...@@ -167,6 +169,8 @@ read_only ...@@ -167,6 +169,8 @@ read_only
boolean boolean
read_only_fallback read_only_fallback
boolean boolean
drop_cache_rather_verify
boolean
username username
string string
password password
...@@ -177,6 +181,12 @@ blob_dir ...@@ -177,6 +181,12 @@ blob_dir
string string
shared_blob_dir shared_blob_dir
boolean boolean
blob_cache_size
bytesize
blob_cache_size_check
integer
client_label
string
Misc Misc
++++ ++++
......
...@@ -108,7 +108,7 @@ class FileStorageURIResolver(Resolver): ...@@ -108,7 +108,7 @@ class FileStorageURIResolver(Resolver):
def factory(): def factory():
filestorage = FileStorage(*args, **kw) filestorage = FileStorage(*args, **kw)
return BlobStorage(blobstorage_dir, filestorage, return BlobStorage(blobstorage_dir, filestorage,
layout=blobstorage_layout) layout=blobstorage_layout)
elif demostorage: elif demostorage:
def factory(): def factory():
filestorage = FileStorage(*args, **kw) filestorage = FileStorage(*args, **kw)
...@@ -124,10 +124,11 @@ class ClientStorageURIResolver(Resolver): ...@@ -124,10 +124,11 @@ class ClientStorageURIResolver(Resolver):
_int_args = ('debug', 'min_disconnect_poll', 'max_disconnect_poll', _int_args = ('debug', 'min_disconnect_poll', 'max_disconnect_poll',
'wait_for_server_on_startup', 'wait', 'wait_timeout', 'wait_for_server_on_startup', 'wait', 'wait_timeout',
'read_only', 'read_only_fallback', 'shared_blob_dir', 'read_only', 'read_only_fallback', 'shared_blob_dir',
'demostorage') 'demostorage', 'drop_cache_rather_verify',
'blob_cache_size_check')
_string_args = ('storage', 'name', 'client', 'var', 'username', _string_args = ('storage', 'name', 'client', 'var', 'username',
'password', 'realm', 'blob_dir') 'password', 'realm', 'blob_dir', 'client_label')
_bytesize_args = ('cache_size', ) _bytesize_args = ('cache_size', 'blob_cache_size')
def __call__(self, uri): def __call__(self, uri):
# urlsplit doesnt understand zeo URLs so force to something that # urlsplit doesnt understand zeo URLs so force to something that
......
...@@ -267,12 +267,65 @@ class TestClientStorageURIResolver(unittest.TestCase): ...@@ -267,12 +267,65 @@ class TestClientStorageURIResolver(unittest.TestCase):
storage.close() storage.close()
ClientStorage.assert_called_once_with('/var/nosuchfile', wait=0) ClientStorage.assert_called_once_with('/var/nosuchfile', wait=0)
@mock.patch('zodburi.resolvers.ClientStorage')
def test_factory_kwargs(self, ClientStorage):
resolver = self._makeOne()
factory, dbkw = resolver('zeo:///var/nosuchfile?'
'storage=main&'
'cache_size=1kb&'
'name=foo&'
'client=bar&'
'var=baz&'
'min_disconnect_poll=2&'
'max_disconnect_poll=3&'
'wait_for_server_on_startup=true&'
'wait=4&'
'wait_timeout=5&'
'read_only=6&'
'read_only_fallback=7&'
'drop_cache_rather_verify=true&'
'username=monty&'
'password=python&'
'realm=blat&'
'blob_dir=some/dir&'
'shared_blob_dir=true&'
'blob_cache_size=1kb&'
'blob_cache_size_check=8&'
'client_label=fink&'
)
storage = factory()
storage.close()
ClientStorage.assert_called_once_with('/var/nosuchfile',
storage='main',
cache_size=1024,
name='foo',
client='bar',
var='baz',
min_disconnect_poll=2,
max_disconnect_poll=3,
wait_for_server_on_startup=1,
wait=4,
wait_timeout=5,
read_only=6,
read_only_fallback=7,
drop_cache_rather_verify=1,
username='monty',
password='python',
realm='blat',
blob_dir='some/dir',
shared_blob_dir=1,
blob_cache_size=1024,
blob_cache_size_check=8,
client_label='fink',
)
@mock.patch('zodburi.resolvers.ClientStorage') @mock.patch('zodburi.resolvers.ClientStorage')
def test_invoke_factory_demostorage(self, ClientStorage): def test_invoke_factory_demostorage(self, ClientStorage):
from ZODB.DemoStorage import DemoStorage from ZODB.DemoStorage import DemoStorage
resolver = self._makeOne() resolver = self._makeOne()
factory, dbkw = resolver('zeo:///var/nosuchfile?wait=false' factory, dbkw = resolver('zeo:///var/nosuchfile?wait=false'
'&demostorage=true') '&demostorage=true')
storage = factory() storage = factory()
storage.close() storage.close()
self.assertTrue(isinstance(storage, DemoStorage)) self.assertTrue(isinstance(storage, DemoStorage))
...@@ -280,9 +333,9 @@ class TestClientStorageURIResolver(unittest.TestCase): ...@@ -280,9 +333,9 @@ class TestClientStorageURIResolver(unittest.TestCase):
def test_dbargs(self): def test_dbargs(self):
resolver = self._makeOne() resolver = self._makeOne()
factory, dbkw = resolver('zeo://localhost:8080?debug=true&' factory, dbkw = resolver('zeo://localhost:8080?debug=true&'
'connection_pool_size=1&' 'connection_pool_size=1&'
'connection_cache_size=1&' 'connection_cache_size=1&'
'database_name=dbname') 'database_name=dbname')
self.assertEqual(dbkw, {'connection_pool_size': '1', self.assertEqual(dbkw, {'connection_pool_size': '1',
'connection_cache_size': '1', 'connection_cache_size': '1',
'database_name': 'dbname'}) 'database_name': 'dbname'})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment