Changeset: 3e8df4423641 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3e8df4423641
Added Files:
clients/python/test/test_control.py
Branch: default
Log Message:
added tests for control module
diffs (125 lines):
diff --git a/clients/python/test/test_control.py
b/clients/python/test/test_control.py
new file mode 100644
--- /dev/null
+++ b/clients/python/test/test_control.py
@@ -0,0 +1,119 @@
+import unittest
+from monetdb.control import Control
+from monetdb.exceptions import OperationalError
+#import logging
+#logging.basicConfig(level=logging.DEBUG)
+
+database_prefix = 'controltest_'
+database_name = database_prefix + 'other'
+passphrase = 'testdb'
+
+def do_without_fail(function):
+ try:
+ function()
+ except OperationalError:
+ pass
+
+class TestManage(unittest.TestCase):
+ def setUp(self):
+ self.control = Control('localhost', 50000, passphrase)
+ do_without_fail(lambda: self.control.stop(database_name))
+ do_without_fail(lambda: self.control.destroy(database_name))
+ self.control.create(database_name)
+
+ def tearDown(self):
+ do_without_fail(lambda: self.control.stop(database_name))
+ do_without_fail(lambda: self.control.destroy(database_name))
+
+ def testCreate(self):
+ create_name = database_prefix + "create"
+ do_without_fail(lambda: self.control.destroy(create_name))
+ self.control.create(create_name)
+ self.assertRaises(OperationalError, self.control.create, create_name)
+ do_without_fail(lambda: self.control.destroy(create_name))
+
+ def testDestroy(self):
+ destroy_name = database_prefix + "destroy"
+ self.control.create(destroy_name)
+ self.control.destroy(destroy_name)
+ self.assertRaises(OperationalError, self.control.destroy, destroy_name)
+
+ def testLock(self):
+ do_without_fail(lambda: self.control.release(database_name))
+ self.control.lock(database_name)
+ self.assertRaises(OperationalError, self.control.lock, database_name)
+
+ def testRelease(self):
+ do_without_fail(lambda: self.control.release(database_name))
+ do_without_fail(lambda: self.control.lock(database_name))
+ self.assertTrue(self.control.release(database_name))
+ self.assertRaises(OperationalError, self.control.release,
database_name)
+
+ def testStatus(self):
+ status1 = database_prefix + "status1"
+ do_without_fail(lambda: self.control.destroy(status1))
+ self.control.create(status1)
+ status = self.control.status(status1)
+ self.assertEquals(status["name"], status1)
+
+ def testStatuses(self):
+ status1 = database_prefix + "status1"
+ status2 = database_prefix + "status2"
+ do_without_fail(lambda: self.control.destroy(status1))
+ do_without_fail(lambda: self.control.destroy(status2))
+ self.control.create(status1)
+ self.control.create(status2)
+ statuses = self.control.status()
+ self.assertTrue(status1 in [status["name"] for status in statuses])
+ self.assertTrue(status2 in [status["name"] for status in statuses])
+ do_without_fail(lambda: self.control.destroy(status1))
+ do_without_fail(lambda: self.control.destroy(status2))
+
+ def testStart(self):
+ do_without_fail(lambda: self.control.stop(database_name))
+ self.assertTrue(self.control.start(database_name))
+
+ def testStop(self):
+ do_without_fail(lambda: self.control.start(database_name))
+ self.assertTrue(self.control.stop(database_name))
+
+ def testKill(self):
+ do_without_fail(lambda: self.control.start(database_name))
+ self.assertTrue(self.control.kill(database_name))
+
+ def testSet(self):
+ property_ = "readonly"
+ value = "yes"
+ self.control.set(database_name, property_, value)
+ properties = self.control.get(database_name)
+ self.assertEqual(properties[property_], value)
+
+ def testGet(self):
+ properties = self.control.get(database_name)
+
+ def testInherit(self):
+ self.control.set(database_name, "readonly", "yes")
+ self.assertTrue(self.control.inherit(database_name, "readonly"))
+ self.assertFalse(self.control.get(database_name).has_key("readonly"))
+
+ def testRename(self):
+ old = database_prefix + "old"
+ new = database_prefix + "new"
+ do_without_fail(lambda: self.control.destroy(old))
+ do_without_fail(lambda: self.control.destroy(new))
+ self.control.create(old)
+ self.control.rename(old, new)
+ statuses = self.control.status()
+ self.assertTrue(new in [status["name"] for status in statuses])
+ do_without_fail(lambda: self.control.destroy(new))
+
+ def testDefaults(self):
+ defaults = self.control.defaults()
+ self.assertTrue(defaults.has_key("readonly"))
+
+ def testNeighbours(self):
+ neighbours = self.control.neighbours()
+ neighbours
+
+if __name__ == '__main__':
+ unittest.main()
\ No newline at end of file
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list