def setUp(self): if os.path.exists("openchange.ldb"): os.unlink("openchange.ldb") self.db = OpenChangeDB("openchange.ldb") self.db.setup() self.names = ProvisionNames() self.names.firstorg = 'firstorg' self.names.firstou = 'firstou' self.names.ocserverdn = 'dc=myserver' self.names.netbiosname = 'myserver'
class OpenChangeDBTests(unittest.TestCase): """Tests for OpenChangeDB.""" def setUp(self): if os.path.exists("openchange.ldb"): os.unlink("openchange.ldb") self.db = OpenChangeDB("openchange.ldb") self.db.setup() self.names = ProvisionNames() self.names.firstorg = 'firstorg' self.names.firstou = 'firstou' self.names.ocserverdn = 'dc=myserver' self.names.netbiosname = 'myserver' def test_user_exists_no_server(self): self.assertRaises(NoSuchServer, self.db.lookup_mailbox_user, "someserver", "foo") def test_server_lookup_doesnt_exist(self): self.assertRaises(NoSuchServer, self.db.lookup_server, "nonexistantserver") def test_server_lookup(self): self.db.add_server(self.names) self.assertEquals( self.names.ocserverdn, str(self.db.lookup_server(self.names.netbiosname)['dn'])) def test_msg_globalcount_initial(self): self.db.add_server(self.names) self.assertEquals( 1, self.db.get_message_GlobalCount(self.names.netbiosname)) def test_set_msg_globalcount(self): self.db.add_server(self.names) self.db.set_message_GlobalCount(self.names.netbiosname, 42) self.assertEquals( 42, self.db.get_message_GlobalCount(self.names.netbiosname)) def test_msg_replicaid_initial(self): self.db.add_server(self.names) self.assertEquals( 1, self.db.get_message_ReplicaID(self.names.netbiosname))
def setUp(self): if os.path.exists("openchange.ldb"): os.unlink("openchange.ldb") self.db = OpenChangeDB("openchange.ldb") self.db.setup()
class OpenChangeDBTests(unittest.TestCase): """Tests for OpenChangeDB.""" def setUp(self): if os.path.exists("openchange.ldb"): os.unlink("openchange.ldb") self.db = OpenChangeDB("openchange.ldb") self.db.setup() def test_server_lookup_doesnt_exist(self): self.assertRaises(NoSuchServer, self.db.lookup_server, "nonexistantserver") def test_server_lookup(self): self.db.add_server("dc=blaserver", "blaserver", "firstorg", "firstou") self.assertEquals("dc=blaserver", str(self.db.lookup_server("blaserver")['dn'])) def test_msg_globalcount_initial(self): self.db.add_server("dc=myserver", "myserver", "firstorg", "firstou") self.assertEquals(1, self.db.get_message_GlobalCount("myserver")) def test_set_msg_globalcount(self): self.db.add_server("dc=myserver", "myserver", "firstorg", "firstou") self.db.set_message_GlobalCount("myserver", 42) self.assertEquals(42, self.db.get_message_GlobalCount("myserver")) def test_msg_replicaid_initial(self): self.db.add_server("dc=myserver", "myserver", "firstorg", "firstou") self.assertEquals(1, self.db.get_message_ReplicaID("myserver"))
class OpenChangeDBTests(unittest.TestCase): """Tests for OpenChangeDB.""" def setUp(self): if os.path.exists("openchange.ldb"): os.unlink("openchange.ldb") self.db = OpenChangeDB("openchange.ldb") self.db.setup() self.names = ProvisionNames() self.names.firstorg = 'firstorg' self.names.firstou = 'firstou' self.names.ocserverdn = 'dc=myserver' self.names.netbiosname = 'myserver' def test_user_exists_no_server(self): self.assertRaises(NoSuchServer, self.db.lookup_mailbox_user, "someserver", "foo") def test_server_lookup_doesnt_exist(self): self.assertRaises(NoSuchServer, self.db.lookup_server, "nonexistantserver") def test_server_lookup(self): self.db.add_server(self.names) self.assertEquals(self.names.ocserverdn, str(self.db.lookup_server(self.names.netbiosname)['dn'])) def test_msg_globalcount_initial(self): self.db.add_server(self.names) self.assertEquals(1, self.db.get_message_GlobalCount(self.names.netbiosname)) def test_set_msg_globalcount(self): self.db.add_server(self.names) self.db.set_message_GlobalCount(self.names.netbiosname, 42) self.assertEquals(42, self.db.get_message_GlobalCount(self.names.netbiosname)) def test_msg_replicaid_initial(self): self.db.add_server(self.names) self.assertEquals(1, self.db.get_message_ReplicaID(self.names.netbiosname))
class OpenChangeDBTests(unittest.TestCase): """Tests for OpenChangeDB.""" def setUp(self): if os.path.exists("openchange.ldb"): os.unlink("openchange.ldb") self.db = OpenChangeDB("openchange.ldb") self.db.setup() def test_user_exists_no_server(self): self.assertRaises(NoSuchServer, self.db.user_exists, "someserver", "foo") def test_server_lookup_doesnt_exist(self): self.assertRaises(NoSuchServer, self.db.lookup_server, "nonexistantserver") def test_server_lookup(self): self.db.add_server("dc=blaserver", "blaserver", "firstorg", "firstou") self.assertEquals("dc=blaserver", str(self.db.lookup_server("blaserver")['dn'])) def test_add_mailbox_user(self): self.db.add_server("cn=myserver", "myserver", "firstorg", "firstou") self.db.add_mailbox_user("cn=firstorg,cn=firstou,cn=myserver", "someuser") self.assertTrue(self.db.user_exists("myserver", "someuser")) def test_msg_globalcount_initial(self): self.db.add_server("dc=myserver", "myserver", "firstorg", "firstou") self.assertEquals(1, self.db.get_message_GlobalCount("myserver")) def test_set_msg_globalcount(self): self.db.add_server("dc=myserver", "myserver", "firstorg", "firstou") self.db.set_message_GlobalCount("myserver", 42) self.assertEquals(42, self.db.get_message_GlobalCount("myserver")) def test_msg_replicaid_initial(self): self.db.add_server("dc=myserver", "myserver", "firstorg", "firstou") self.assertEquals(1, self.db.get_message_ReplicaID("myserver"))