Beispiel #1
0
 def test_delete(self):
     """Test object deletion
     """
     pg = PosixGroup(LDAP_CONN)
     pg.name = u'TestDelete'
     pg.gid = 9351
     pg.members = [23, 32]
     pg.set_parent('ou=groups,dc=company,dc=com')
     pg.save()
     pg.delete()
     self.assertEqual(pg.isnew(), True)
     self.assertEqual(
         pg.dn, u'cn=TestDelete,ou=groups,dc=company,dc=com')
     pg.set_parent(u'dc=company,dc=com')
     pg.name = u'TestDelete2'
     pg.save()
     self.assertEqual(pg.dn, u'cn=TestDelete2,dc=company,dc=com')
     pg.delete()
Beispiel #2
0
    def test_create_object(self):
        """Test creating new object, removing single attribute, deleting object
        """
        pg = PosixGroup(LDAP_CONN)
        pg.name = u'Test group'
        pg.gid = 1234
        pg.members = [1, 2, 3, 4, 5]
        pg.remove_member(3)
        pg.set_parent('ou=groups,dc=company,dc=com')
        pg.save()

        self.assertEqual(pg.dn, 'cn=Test group,ou=groups,dc=company,dc=com')

        del pg.members
        pg.save()

        pgtest = PosixGroup(LDAP_CONN, pg.dn)
        self.assertEqual(pgtest.object_class, [u'posixGroup'])
        self.assertEqual(pgtest.name, u'Test group')
        self.assertEqual(pgtest.gid, 1234)
        self.assertEqual(pgtest.members, [])

        pg.delete()