|
@@ -0,0 +1,47 @@
|
|
|
+# Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
|
|
|
+#
|
|
|
+# Permission to use, copy, modify, and distribute this software for any
|
|
|
+# purpose with or without fee is hereby granted, provided that the above
|
|
|
+# copyright notice and this permission notice appear in all copies.
|
|
|
+#
|
|
|
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
|
|
|
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
|
|
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
+
|
|
|
+import unittest
|
|
|
+import isc.log
|
|
|
+import isc.bind10.socket_cache
|
|
|
+
|
|
|
+class SocketCacheTest(unittest.TestCase):
|
|
|
+ """
|
|
|
+ Some tests for the isc.bind10.socket_cache.Cache.
|
|
|
+
|
|
|
+ This class, as well as being the testcase, pretends to be the
|
|
|
+ socket creator so it can hijack all the requests for sockets.
|
|
|
+ """
|
|
|
+ def setUp(self):
|
|
|
+ """
|
|
|
+ Creates the cache for tests with us being the socket creator.
|
|
|
+ """
|
|
|
+ self.__cache = isc.bind10.socket_cache.Cache(self)
|
|
|
+
|
|
|
+ def test_init(self):
|
|
|
+ """
|
|
|
+ Checks the internals of the cache just after the creation.
|
|
|
+ """
|
|
|
+ self.assertEqual(self, self.__cache._creator)
|
|
|
+ self.assertEqual({}, self.__cache._waiting_tokens)
|
|
|
+ self.assertEqual({}, self.__cache._active_tokens)
|
|
|
+ self.assertEqual({}, self.__cache._active_apps)
|
|
|
+ self.assertEqual({}, self.__cache._sockets)
|
|
|
+ self.assertEqual(set(), self.__cache._live_tokens)
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ isc.log.init("bind10")
|
|
|
+ isc.log.resetUnitTestRootLogger()
|
|
|
+ unittest.main()
|