Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
ryu/tests/unit/lib/test_rpc.py | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/ryu/tests/unit/lib/test_rpc.py b/ryu/tests/unit/lib/test_rpc.py
index 779a85d..735e049 100644
--- a/ryu/tests/unit/lib/test_rpc.py
+++ b/ryu/tests/unit/lib/test_rpc.py
@@ -48,6 +48,11 @@ class Test_rpc(unittest.TestCase):
elif method == "notify1":
e.send_notification(params[1], params[2])
e.send_response(msgid, result=params[0])
+ elif method == "shutdown":
+ import socket
+ how = getattr(socket, params[0])
+ self._server_sock.shutdown(how)
+ e.send_response(msgid, result=method)
else:
raise Exception("unknown method %s" % method)
@@ -72,15 +77,16 @@ class Test_rpc(unittest.TestCase):
def setUp(self):
import socket
- server_sock, self._client_sock = socket.socketpair()
+ self._server_sock, self._client_sock = socket.socketpair()
table = {
rpc.MessageType.REQUEST: self._handle_request,
rpc.MessageType.RESPONSE: self._handle_response,
rpc.MessageType.NOTIFY: self._handle_notification
}
self._requests = set()
- server_sock.setblocking(0)
- self._server_endpoint = rpc.EndPoint(server_sock, disp_table=table)
+ self._server_sock.setblocking(0)
+ self._server_endpoint = rpc.EndPoint(self._server_sock,
+ disp_table=table)
self._server_thread = hub.spawn(self._server_endpoint.serve)
def tearDown(self):
@@ -144,11 +150,16 @@ class Test_rpc(unittest.TestCase):
assert isinstance(result, bytes)
def test_1_shutdown_wr(self):
- # test if the server shutdown on disconnect
+ # test if the server shutdown on disconnect
import socket
self._client_sock.shutdown(socket.SHUT_WR)
hub.joinall([self._server_thread])
+ @raises(EOFError)
+ def test_1_client_shutdown_wr(self):
+ c = rpc.Client(self._client_sock)
+ c.call("shutdown", ["SHUT_WR"])
+
def test_1_call_True(self):
c = rpc.Client(self._client_sock)
obj = True
--
1.8.1.5
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel