BIND 10 trac346, updated. ed89ba2b9f20a5aad5f213191f9b34981aa6a0b9 [trac346] add a remote end for MockSocket for testing

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Feb 18 01:21:38 UTC 2011


The branch, trac346 has been updated
       via  ed89ba2b9f20a5aad5f213191f9b34981aa6a0b9 (commit)
      from  9cf88a2d14abccc7b3ad6ffd8d299dfa464bee1c (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 ed89ba2b9f20a5aad5f213191f9b34981aa6a0b9
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date:   Fri Feb 18 09:20:41 2011 +0800

    [trac346] add a remote end for MockSocket for testing

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

Summary of changes:
 src/lib/python/isc/notify/tests/notify_out_test.py |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/notify/tests/notify_out_test.py b/src/lib/python/isc/notify/tests/notify_out_test.py
index a605704..c4c149c 100644
--- a/src/lib/python/isc/notify/tests/notify_out_test.py
+++ b/src/lib/python/isc/notify/tests/notify_out_test.py
@@ -27,25 +27,29 @@ class MockSocket():
     def __init__(self, family, type):
         self.family = family
         self.type = type
-        self._read_sock, self._write_sock  = socket.socketpair()
+        self._local_sock, self._remote_sock = socket.socketpair()
 
     def connect(self, to):
         pass
 
     def fileno(self):
-        return self._read_sock.fileno()
+        return self._local_sock.fileno()
 
     def close(self):
-        self._read_sock.close()
-        self._write_sock.close()
+        self._local_sock.close()
+        self._remote_sock.close()
 
     def sendto(self, data, flag, dst):
-        return self._write_sock.send(data)
+        return self._local_sock.send(data)
 
     def recvfrom(self, length):
-        data = self._read_sock.recv(length)
+        data = self._local_sock.recv(length)
         return (data, None)
 
+    # provide a remote end which can write data to MockSocket for testing.
+    def remote_end(self):
+        return self._remote_sock
+
 # We subclass the ZoneNotifyInfo class we're testing here, only
 # to override the prepare_notify_out() method.
 class MockZoneNotifyInfo(notify_out.ZoneNotifyInfo):
@@ -137,12 +141,11 @@ class TestNotifyOut(unittest.TestCase):
         self.assertEqual(len(timeout_zones), 2)
 
         # Now make one socket be readable
-        addr = ('localhost', 12340)
         self._notify._notify_infos[('example.net.', 'IN')].notify_timeout = time.time() + 10
         self._notify._notify_infos[('example.com.', 'IN')].notify_timeout = time.time() + 10
 
         #Send some data to socket 12340, to make the target socket be readable
-        self._notify._notify_infos[('example.net.', 'IN')]._sock.sendto(b'data', 0, addr)
+        self._notify._notify_infos[('example.net.', 'IN')]._sock.remote_end().send(b'data')
         replied_zones, timeout_zones = self._notify._wait_for_notify_reply()
         self.assertEqual(len(replied_zones), 1)
         self.assertEqual(len(timeout_zones), 1)




More information about the bind10-changes mailing list