summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2010-01-13 17:38:35 +0100
committerRob Crittenden <rcritten@redhat.com>2010-01-13 13:39:50 -0500
commit0023ffb88181f86f2c155c16265c09bd56345237 (patch)
tree20a1f36721605981ee5aa92769204882c1161698 /tests/test_ipalib
parente1c1f077c0ca95f138eee768313e75dba1c6c5db (diff)
downloadfreeipa-0023ffb88181f86f2c155c16265c09bd56345237.tar.gz
freeipa-0023ffb88181f86f2c155c16265c09bd56345237.tar.xz
freeipa-0023ffb88181f86f2c155c16265c09bd56345237.zip
Fix backend.Executioner unit test.
Before the patch that allows to create unshared instances of Connectible objects, all Connection object were deleted at once in destroy_context(). It made sense at the time, because there was always at most one Connection per Connectible subclass and Connectible.disconnect() was called only internally by the Executioner class. Now that we can make arbitrary connections, it makes more sense to delete the Connection object when Connectible.disconnect() is called.
Diffstat (limited to 'tests/test_ipalib')
-rw-r--r--tests/test_ipalib/test_backend.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/test_ipalib/test_backend.py b/tests/test_ipalib/test_backend.py
index 3c29ee35f..82cf17aac 100644
--- a/tests/test_ipalib/test_backend.py
+++ b/tests/test_ipalib/test_backend.py
@@ -45,9 +45,14 @@ class test_Backend(ClassChecker):
class Disconnect(object):
called = False
+ def __init__(self, id=None):
+ self.id = id
+
def __call__(self):
assert self.called is False
self.called = True
+ if self.id is not None:
+ delattr(context, self.id)
class test_Connectible(ClassChecker):
@@ -207,11 +212,13 @@ class test_Executioner(ClassChecker):
o.finalize()
# Test that CommandError is raised:
- conn = Connection('The connection.', Disconnect())
+ conn = Connection('The connection.', Disconnect('someconn'))
context.someconn = conn
+ print str(context.__dict__.keys())
e = raises(errors.CommandError, o.execute, 'nope')
assert e.name == 'nope'
assert conn.disconnect.called is True # Make sure destroy_context() was called
+ print str(context.__dict__.keys())
assert context.__dict__.keys() == []
# Test with echo command:
@@ -220,7 +227,7 @@ class test_Executioner(ClassChecker):
args = (arg1,) + arg2
options = dict(option1=u'How are you?', option2=unicode_str)
- conn = Connection('The connection.', Disconnect())
+ conn = Connection('The connection.', Disconnect('someconn'))
context.someconn = conn
assert o.execute('echo', arg1, arg2, **options) == dict(
result=(arg1, arg2, options)
@@ -228,7 +235,7 @@ class test_Executioner(ClassChecker):
assert conn.disconnect.called is True # Make sure destroy_context() was called
assert context.__dict__.keys() == []
- conn = Connection('The connection.', Disconnect())
+ conn = Connection('The connection.', Disconnect('someconn'))
context.someconn = conn
assert o.execute('echo', *args, **options) == dict(
result=(arg1, arg2, options)
@@ -237,7 +244,7 @@ class test_Executioner(ClassChecker):
assert context.__dict__.keys() == []
# Test with good command:
- conn = Connection('The connection.', Disconnect())
+ conn = Connection('The connection.', Disconnect('someconn'))
context.someconn = conn
e = raises(errors.ValidationError, o.execute, 'good')
assert e.name == 'nurse'
@@ -246,13 +253,13 @@ class test_Executioner(ClassChecker):
assert context.__dict__.keys() == []
# Test with bad command:
- conn = Connection('The connection.', Disconnect())
+ conn = Connection('The connection.', Disconnect('someconn'))
context.someconn = conn
e = raises(errors.InternalError, o.execute, 'bad')
assert conn.disconnect.called is True # Make sure destroy_context() was called
assert context.__dict__.keys() == []
# Test with option 'name':
- conn = Connection('The connection.', Disconnect())
+ conn = Connection('The connection.', Disconnect('someconn'))
context.someconn = conn
assert o.execute('with_name', name=u'test') == dict(result=u'TEST')