[svn] commit: r1900 - /branches/trac183/src/bin/msgq/tests/msgq_test.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 21 12:35:32 UTC 2010
Author: jelte
Date: Fri May 21 12:35:32 2010
New Revision: 1900
Log:
TDD: created tests first :)
Modified:
branches/trac183/src/bin/msgq/tests/msgq_test.py
Modified: branches/trac183/src/bin/msgq/tests/msgq_test.py
==============================================================================
--- branches/trac183/src/bin/msgq/tests/msgq_test.py (original)
+++ branches/trac183/src/bin/msgq/tests/msgq_test.py Fri May 21 12:35:32 2010
@@ -1,6 +1,7 @@
from msgq import SubscriptionManager, MsgQ
import unittest
+import os
#
# Currently only the subscription part is implemented... I'd have to mock
@@ -58,5 +59,35 @@
self.sm.subscribe('g1', '*', 's2')
self.assertEqual(self.sm.find_sub("g1", "i1"), [ 's1' ])
+ def test_open_socket_parameter(self):
+ self.assertFalse(os.path.exists("./my_socket_file"))
+ msgq = MsgQ("./my_socket_file");
+ self.assertTrue(os.path.exists("./my_socket_file"))
+ msgq.shutdown();
+ self.assertFalse(os.path.exists("./my_socket_file"))
+
+ def test_open_socket_environment_variable(self):
+ self.assertFalse(os.path.exists("my_socket_file"))
+ os.environ["BIND10_MSGQ_SOCKET_FILE"] = "./my_socket_file"
+ msgq = MsgQ();
+ self.assertTrue(os.path.exists("./my_socket_file"))
+ msgq.shutdown();
+ self.assertFalse(os.path.exists("./my_socket_file"))
+
+ def test_open_socket_default(self):
+ if "BIND10_MSGQ_SOCKET_FILE" in os.environ:
+ del os.environ["BIND10_MSGQ_SOCKET_FILE"]
+ socket_file = MsgQ.SOCKET_FILE
+ self.assertFalse(os.path.exists(socket_file))
+ msgq = MsgQ();
+ self.assertTrue(os.path.exists("./my_socket_file"))
+ msgq.shutdown();
+ self.assertFalse(os.path.exists("./my_socket_file"))
+ pass
+
+ def test_open_socket_bad(self):
+ self.assertRaises(Exception, MsgQ("/does/not/exist"))
+ pass
+
if __name__ == '__main__':
unittest.main()
More information about the bind10-changes
mailing list