BIND 10 trac2922, updated. a8186631e5cd811b2ebf8df6d837182ea39177ea [2922] Test it tries to send the notifications

BIND 10 source code commits bind10-changes at lists.isc.org
Fri May 31 08:17:25 UTC 2013


The branch, trac2922 has been updated
       via  a8186631e5cd811b2ebf8df6d837182ea39177ea (commit)
      from  6ca9ce763678cd8ce47680d083eeee299889427a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a8186631e5cd811b2ebf8df6d837182ea39177ea
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Fri May 31 10:17:10 2013 +0200

    [2922] Test it tries to send the notifications

-----------------------------------------------------------------------

Summary of changes:
 src/bin/msgq/tests/msgq_test.py |   52 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

-----------------------------------------------------------------------
diff --git a/src/bin/msgq/tests/msgq_test.py b/src/bin/msgq/tests/msgq_test.py
index d79ea8a..d968763 100644
--- a/src/bin/msgq/tests/msgq_test.py
+++ b/src/bin/msgq/tests/msgq_test.py
@@ -240,6 +240,58 @@ class MsgQTest(unittest.TestCase):
         # Omitting the parameters completely in such case is OK
         check_both(self.__msgq.command_handler('members', None))
 
+    def test_notifies(self):
+        """
+        Test the message queue sends notifications about connecting,
+        disconnecting and subscription changes.
+        """
+        # Mock the method to send notifications (we don't really want
+        # to send them now, just see they'd be sent).
+        # Mock the poller, as we don't need it at all (and we don't have
+        # real socket to give it now).
+        notifications = []
+        def send_notification(event, params):
+            notifications.append((event, params))
+        class FakePoller:
+            def register(self, socket, mode):
+                pass
+            def unregister(self, fd, sock):
+                pass
+        self.__msgq.members_notify = send_notification
+        self.__msgq.poller = FakePoller()
+
+        # Create a socket
+        class Sock:
+            def __init__(self, fileno):
+                self.fileno = lambda: fileno
+        sock = Sock(1)
+
+        # We should notify about new cliend when we register it
+        self.__msgq.register_socket(sock)
+        lname = list(self.__msgq.lnames.keys())[0] # Steal the lname
+        self.assertEqual([('connected', {'client': lname})], notifications)
+        notifications.clear()
+
+        # A notification should happen for a subscription to a group
+        self.__msgq.process_command_subscribe(sock, {'group': 'G',
+                                                     'instance': '*'},
+                                              None)
+        self.assertEqual([('subscribed', {'client': lname, 'group': 'G'})],
+                         notifications)
+        notifications.clear()
+
+        # As well for unsubscription
+        self.__msgq.process_command_unsubscribe(sock, {'group': 'G',
+                                                       'instance': '*'},
+                                                None)
+        self.assertEqual([('unsubscribed', {'client': lname, 'group': 'G'})],
+                         notifications)
+        notifications.clear()
+
+        # And, finally, for removal of client
+        self.__msgq.kill_socket(sock.fileno(), sock)
+        self.assertEqual([('disconnected', {'client': lname})], notifications)
+
     def test_undeliverable_errors(self):
         """
         Send several packets through the MsgQ and check it generates



More information about the bind10-changes mailing list