Commit 81fc69e1 authored by Jim Fulton's avatar Jim Fulton

Allow bytes units for large_record_size

parent dc8cb352
......@@ -23,6 +23,9 @@ connection_parameters = '''
historical_timeout large_record_size
'''.strip().split()
bytes_parameters = (
'cache_size_bytes', 'historical_cache_size_bytes', 'large_record_size')
parameters = dict(database_name = 'database_name')
for parameter in connection_parameters:
parameters['connection_' + parameter] = parameter
......@@ -47,7 +50,7 @@ def _get_dbkw(kw):
if parameter in kw:
v = kw.pop(parameter)
if parameter.startswith('connection_'):
if parameter.endswith('_bytes'):
if parameters[parameter] in bytes_parameters:
v = _parse_bytes(v)
else:
v = int(v)
......
......@@ -461,7 +461,7 @@ class TestZConfigURIResolver(unittest.TestCase):
'database_name': 'foo'})
def test_database_all_options(self):
from zodburi import connection_parameters
from zodburi import connection_parameters, bytes_parameters
self.tmp.write(("""
<zodb x>
<mappingstorage>
......@@ -471,7 +471,7 @@ class TestZConfigURIResolver(unittest.TestCase):
</zodb>
""" % '\n'.join("%s %s" % (
name.replace('_', '-'),
'%sMB' % i if name.endswith('_bytes') else i,
'%sMB' % i if name in bytes_parameters else i,
)
for (i, name)
in enumerate(connection_parameters)
......@@ -484,10 +484,10 @@ class TestZConfigURIResolver(unittest.TestCase):
self.assertTrue(isinstance(storage, MappingStorage))
expect = dict(database_name='foo')
for i, parameter in enumerate(connection_parameters):
parameter = 'connection_' + parameter
expect[parameter] = i
if parameter.endswith('_bytes'):
expect[parameter] *= 1<<20
cparameter = 'connection_' + parameter
expect[cparameter] = i
if parameter in bytes_parameters:
expect[cparameter] *= 1<<20
self.assertEqual(dbkw, expect)
class TestMappingStorageURIResolver(Base, unittest.TestCase):
......
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