summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ipalib/test_rpc.py16
-rw-r--r--tests/util.py7
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_ipalib/test_rpc.py b/tests/test_ipalib/test_rpc.py
index bc8936ab6..30175e3bf 100644
--- a/tests/test_ipalib/test_rpc.py
+++ b/tests/test_ipalib/test_rpc.py
@@ -22,7 +22,7 @@ Test the `ipalib.rpc` module.
"""
import threading
-from xmlrpclib import Binary, Fault, dumps, loads
+from xmlrpclib import Binary, Fault, dumps, loads, ServerProxy
from tests.util import raises, assert_equal, PluginTester, DummyClass
from tests.data import binary_bytes, utf8_bytes, unicode_str
from ipalib.frontend import Command
@@ -184,6 +184,20 @@ class test_xmlclient(PluginTester):
"""
_plugin = rpc.xmlclient
+ def test_connect(self):
+ (o, api, home) = self.instance('Backend', in_server=False)
+
+ # Test that StandardError is raised if conntext.xmlconn already exists:
+ context.xmlconn = 'The xmlrpclib.ServerProxy instance'
+ e = raises(StandardError, o.connect)
+ assert str(e) == '%s.connect(): context.%s already exists in thread %r' % (
+ 'xmlclient', 'xmlconn', threading.currentThread().getName()
+ )
+
+ del context.xmlconn
+ o.connect()
+ assert isinstance(context.xmlconn, ServerProxy)
+
def test_forward(self):
"""
Test the `ipalib.rpc.xmlclient.forward` method.
diff --git a/tests/util.py b/tests/util.py
index f5899dfab..631d4a05c 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -295,6 +295,13 @@ class PluginTester(object):
o = api[namespace][self.plugin.__name__]
return (o, api, home)
+ def tearDown(self):
+ """
+ nose tear-down fixture.
+ """
+ for name in context.__dict__.keys():
+ delattr(context, name)
+
class dummy_ugettext(object):
__called = False