From 5866e257b6a1a3ef22f4080d7de2f448e37f1d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 15 Feb 2012 11:45:36 +0000 Subject: [PATCH] tests: fix LdapDNS to allow running test_network in isolation * nova/tests/test_network.py (LdapDNSTestCase): Since the ldapdns module imports ldap unconditionally, the following will not run on a system without python-ldap installed ./run_tests.sh test_network Therefore ensure the fake ldap module is used, as is the case when running the full test suite. Change-Id: If92c613bf2684c25cdadf2ac7f53f2005979b2b6 --- nova/tests/test_network.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 9e313ae5..24ea02d2 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -16,6 +16,7 @@ # License for the specific language governing permissions and limitations # under the License. import mox +import sys from nova import context from nova import db @@ -1511,6 +1512,11 @@ class LdapDNSTestCase(test.TestCase): """Tests nova.network.ldapdns.LdapDNS""" def setUp(self): super(LdapDNSTestCase, self).setUp() + + self.saved_ldap = sys.modules.get('ldap') + import nova.auth.fakeldap + sys.modules['ldap'] = nova.auth.fakeldap + temp = utils.import_object('nova.network.ldapdns.FakeLdapDNS') self.driver = temp self.driver.create_domain(domain1) @@ -1520,6 +1526,7 @@ class LdapDNSTestCase(test.TestCase): super(LdapDNSTestCase, self).tearDown() self.driver.delete_domain(domain1) self.driver.delete_domain(domain2) + sys.modules['ldap'] = self.saved_ldap def test_ldap_dns_domains(self): domains = self.driver.get_domains()