From 8ca9ba946e1762d533edfae797137afcc8873dd3 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 2 Oct 2012 14:23:32 -0700 Subject: Remove dependency on python-ldap for tests We have a fake ldap implementation for testing, but the tests still fail if ldap isn't installed. This modifies the usage of ldap in the LdapDNS tests to stub the module before attempting to import it. This allows us to test without having python-ldap installed. It removes the unneccessary FakeLdapDNS in favor of using the real LdapDNS with the module stubbed out. It also removes the dependency on python-ldap from test-requires. Change-Id: Ifbe09e16436afa6999dcb7385763492b0026556c --- nova/tests/network/test_manager.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'nova') diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index c24bee2d8..ca98587c9 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -17,13 +17,11 @@ # under the License. import mox import shutil -import sys import tempfile from nova import context from nova import db from nova import exception -from nova.network import ldapdns from nova.network import linux_net from nova.network import manager as network_manager from nova.openstack.common import importutils @@ -1829,26 +1827,20 @@ domain1 = "example.org" domain2 = "example.com" -class FakeLdapDNS(ldapdns.LdapDNS): - """For testing purposes, a DNS driver backed with a fake ldap driver.""" - def __init__(self): - self.lobj = fake_ldap.FakeLDAP() - attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain', - 'domain', 'dcobject', 'top'], - 'associateddomain': ['root'], - 'dc': ['root']} - self.lobj.add_s("ou=hosts,dc=example,dc=org", - ldapdns.create_modlist(attrs)) - - class LdapDNSTestCase(test.TestCase): """Tests nova.network.ldapdns.LdapDNS""" def setUp(self): super(LdapDNSTestCase, self).setUp() self.stub_module('ldap', fake_ldap) + dns_class = 'nova.network.ldapdns.LdapDNS' + self.driver = importutils.import_object(dns_class) - self.driver = FakeLdapDNS() + attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain', + 'domain', 'dcobject', 'top'], + 'associateddomain': ['root'], + 'dc': ['root']} + self.driver.lobj.add_s("ou=hosts,dc=example,dc=org", attrs.items()) self.driver.create_domain(domain1) self.driver.create_domain(domain2) -- cgit