|
10 |
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.path.pardir, 'python')) |
10 |
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.path.pardir, 'python')) |
11 |
from univention.config_registry.backend import ConfigRegistry |
11 |
from univention.config_registry.backend import ConfigRegistry |
12 |
|
12 |
|
|
|
13 |
|
13 |
class TestConfigRegistry(unittest.TestCase): |
14 |
class TestConfigRegistry(unittest.TestCase): |
14 |
"""Unit test for univention.config_registry.backend.ConfigRegistry""" |
15 |
"""Unit test for univention.config_registry.backend.ConfigRegistry""" |
15 |
def setUp(self): |
16 |
def setUp(self): |
Lines 219-243
class TestConfigRegistry(unittest.TestCase):
|
Link Here
|
---|
|
219 |
"""Test valid is_true().""" |
220 |
"""Test valid is_true().""" |
220 |
ucr = ConfigRegistry() |
221 |
ucr = ConfigRegistry() |
221 |
for ucr['foo'] in ('YES', 'yes', 'Yes', 'true', '1', 'enable', 'enabled', 'on'): |
222 |
for ucr['foo'] in ('YES', 'yes', 'Yes', 'true', '1', 'enable', 'enabled', 'on'): |
222 |
self.assertTrue(ucr.is_true('foo')) |
223 |
self.assertTrue(ucr.is_true('foo'), 'is_true(%(foo)r)' % ucr) |
223 |
|
224 |
|
224 |
def test_is_true_invalid(self): |
225 |
def test_is_true_invalid(self): |
225 |
"""Test invalid is_true().""" |
226 |
"""Test invalid is_true().""" |
226 |
ucr = ConfigRegistry() |
227 |
ucr = ConfigRegistry() |
227 |
for ucr['foo'] in ('yes ', ' yes', ''): |
228 |
for ucr['foo'] in ('yes ', ' yes', ''): |
228 |
self.assertFalse(ucr.is_true('foo')) |
229 |
self.assertFalse(ucr.is_true('foo'), 'is_true(%(foo)r)' % ucr) |
229 |
|
230 |
|
230 |
def test_is_true_valid_direct(self): |
231 |
def test_is_true_valid_direct(self): |
231 |
"""Test valid is_true(value).""" |
232 |
"""Test valid is_true(value).""" |
232 |
ucr = ConfigRegistry() |
233 |
ucr = ConfigRegistry() |
233 |
for value in ('yes', 'true', '1', 'enable', 'enabled', 'on'): |
234 |
for value in ('YES', 'Yes', 'yes', 'true', '1', 'enable', 'enabled', 'on'): |
234 |
self.assertTrue(ucr.is_true(value=value)) |
235 |
self.assertTrue(ucr.is_true(value=value), 'is_true(v=%r)' % value) |
235 |
|
236 |
|
236 |
def test_is_true_invalid_direct(self): |
237 |
def test_is_true_invalid_direct(self): |
237 |
"""Test invalid is_true(value).""" |
238 |
"""Test invalid is_true(value).""" |
238 |
ucr = ConfigRegistry() |
239 |
ucr = ConfigRegistry() |
239 |
for value in ('YES', 'Yes', 'yes ', ' yes', ''): |
240 |
for value in ('yes ', ' yes', ''): |
240 |
self.assertFalse(ucr.is_true(value=value)) |
241 |
self.assertFalse(ucr.is_true(value=value), 'is_true(v=%r)' % value) |
241 |
|
242 |
|
242 |
def test_is_false_unset(self): |
243 |
def test_is_false_unset(self): |
243 |
"""Test unset is_false().""" |
244 |
"""Test unset is_false().""" |
Lines 254-278
class TestConfigRegistry(unittest.TestCase):
|
Link Here
|
---|
|
254 |
"""Test valid is_false().""" |
255 |
"""Test valid is_false().""" |
255 |
ucr = ConfigRegistry() |
256 |
ucr = ConfigRegistry() |
256 |
for ucr['foo'] in ('NO', 'no', 'No', 'false', '0', 'disable', 'disabled', 'off'): |
257 |
for ucr['foo'] in ('NO', 'no', 'No', 'false', '0', 'disable', 'disabled', 'off'): |
257 |
self.assertTrue(ucr.is_false('foo')) |
258 |
self.assertTrue(ucr.is_false('foo'), 'is_false(%(foo)r)' % ucr) |
258 |
|
259 |
|
259 |
def test_is_false_invalid(self): |
260 |
def test_is_false_invalid(self): |
260 |
"""Test invalid is_false().""" |
261 |
"""Test invalid is_false().""" |
261 |
ucr = ConfigRegistry() |
262 |
ucr = ConfigRegistry() |
262 |
for ucr['foo'] in ('no ', ' no', ''): |
263 |
for ucr['foo'] in ('no ', ' no', ''): |
263 |
self.assertFalse(ucr.is_false('foo')) |
264 |
self.assertFalse(ucr.is_false('foo'), 'is_false(%(foo)r)' % ucr) |
264 |
|
265 |
|
265 |
def test_is_false_valid_direct(self): |
266 |
def test_is_false_valid_direct(self): |
266 |
"""Test valid is_false(value).""" |
267 |
"""Test valid is_false(value).""" |
267 |
ucr = ConfigRegistry() |
268 |
ucr = ConfigRegistry() |
268 |
for value in ('no', 'false', '0', 'disable', 'disabled', 'off'): |
269 |
for value in ('NO', 'No', 'no', 'false', '0', 'disable', 'disabled', 'off'): |
269 |
self.assertTrue(ucr.is_false(value=value)) |
270 |
self.assertTrue(ucr.is_false(value=value), 'is_false(v=%r)' % value) |
270 |
|
271 |
|
271 |
def test_is_false_invalid_direct(self): |
272 |
def test_is_false_invalid_direct(self): |
272 |
"""Test valid is_false(value).""" |
273 |
"""Test valid is_false(value).""" |
273 |
ucr = ConfigRegistry() |
274 |
ucr = ConfigRegistry() |
274 |
for value in ('NO', 'No', 'no ', ' no', ''): |
275 |
for value in ('no ', ' no', ''): |
275 |
self.assertFalse(ucr.is_false(value=value)) |
276 |
self.assertFalse(ucr.is_false(value=value), 'is_false(v=%r)' % value) |
276 |
|
277 |
|
277 |
def test_update(self): |
278 |
def test_update(self): |
278 |
"""Test update().""" |
279 |
"""Test update().""" |
279 |
- |
|
|
280 |
- UMC doesn't do the locking, but even with it it fails. |
280 |
- UMC doesn't do the locking, but even with it it fails. |
281 |
- moving the "assertEqual()" inside the locks makes the problem go |
281 |
- moving the "assertEqual()" inside the locks makes the problem go |
282 |
away, as then a concurrent "clear()" can not get in between. |
282 |
away, as then a concurrent "clear()" can not get in between. |
283 |
-- |
|
|
284 |
.../base/univention-config-registry/debian/rules | 1 + |
283 |
.../base/univention-config-registry/debian/rules | 1 + |
285 |
.../python/univention/config_registry/backend.py | 27 ++++---- |
284 |
.../python/univention/config_registry/backend.py | 27 ++++---- |
286 |
.../tests/test_backend_threading.py | 78 ++++++++++++++++++++++ |
285 |
.../tests/test_backend_threading.py | 78 ++++++++++++++++++++++ |
287 |
3 files changed, 92 insertions(+), 14 deletions(-) |
286 |
3 files changed, 92 insertions(+), 14 deletions(-) |
288 |
create mode 100644 branches/ucs-4.1/ucs-4.1-0/base/univention-config-registry/tests/test_backend_threading.py |
287 |
create mode 100644 branches/ucs-4.1/ucs-4.1-0/base/univention-config-registry/tests/test_backend_threading.py |