+class ScopedTestCase(BaseTestCase):
+ def setUp(self):
+ super(ScopedTestCase, self).setUp()
+
+ cursor = ldapdb.connection._cursor()
+ self.scoped_dn = "ou=contacts,%s" % LdapGroup.base_dn
+ attrs = [('objectClass', ['top', 'organizationalUnit']), ("ou", ["contacts"])]
+ cursor.connection.add_s(self.scoped_dn, attrs)
+
+ def test_scope(self):
+ ScopedGroup = LdapGroup.scoped(self.scoped_dn)
+
+ # create group
+ g = LdapGroup()
+ g.name = "foogroup"
+ g.gid = 1000
+ g.save()
+
+ qs = LdapGroup.objects.all()
+ self.assertEquals(qs.count(), 1)
+
+ qs = ScopedGroup.objects.all()
+ self.assertEquals(qs.count(), 0)
+
+ # create scoped group
+ g2 = ScopedGroup()
+ g2.name = "scopedgroup"
+ g2.gid = 5000
+ g2.save()
+
+ qs = LdapGroup.objects.all()
+ self.assertEquals(qs.count(), 2)
+
+ qs = ScopedGroup.objects.all()
+ self.assertEquals(qs.count(), 1)
+