tests/test-wireproto-serverreactor.py
changeset 40135 966b5f7fd30b
parent 40129 293835e0fff7
child 40136 3a6d6c54bd81
--- a/tests/test-wireproto-serverreactor.py	Fri Oct 05 09:23:06 2018 -0700
+++ b/tests/test-wireproto-serverreactor.py	Fri Oct 05 10:29:36 2018 -0700
@@ -225,19 +225,22 @@
         results.append(self._sendsingleframe(
             reactor, ffs(b'1 1 stream-begin command-request new '
                          b"cbor:{b'name': b'command'}")))
-        result = reactor.oncommandresponseready(outstream, 1, b'response1')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [b'response1'])
         self.assertaction(result, b'sendframes')
         list(result[1][b'framegen'])
         results.append(self._sendsingleframe(
             reactor, ffs(b'1 1 stream-begin command-request new '
                          b"cbor:{b'name': b'command'}")))
-        result = reactor.oncommandresponseready(outstream, 1, b'response2')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [b'response2'])
         self.assertaction(result, b'sendframes')
         list(result[1][b'framegen'])
         results.append(self._sendsingleframe(
             reactor, ffs(b'1 1 stream-begin command-request new '
                          b"cbor:{b'name': b'command'}")))
-        result = reactor.oncommandresponseready(outstream, 1, b'response3')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [b'response3'])
         self.assertaction(result, b'sendframes')
         list(result[1][b'framegen'])
 
@@ -364,10 +367,13 @@
         list(sendcommandframes(reactor, instream, 1, b'mycommand', {}))
 
         outstream = reactor.makeoutputstream()
-        result = reactor.oncommandresponseready(outstream, 1, b'response')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [b'response'])
         self.assertaction(result, b'sendframes')
         self.assertframesequal(result[1][b'framegen'], [
-            b'1 2 stream-begin command-response eos %sresponse' % OK,
+            b'1 2 stream-begin command-response continuation %s' % OK,
+            b'1 2 0 command-response continuation cbor:b"response"',
+            b'1 2 0 command-response eos ',
         ])
 
     def testmultiframeresponse(self):
@@ -380,12 +386,16 @@
         list(sendcommandframes(reactor, instream, 1, b'mycommand', {}))
 
         outstream = reactor.makeoutputstream()
-        result = reactor.oncommandresponseready(outstream, 1, first + second)
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [first + second])
         self.assertaction(result, b'sendframes')
         self.assertframesequal(result[1][b'framegen'], [
             b'1 2 stream-begin command-response continuation %s' % OK,
+            b'1 2 0 command-response continuation Y\x80d',
             b'1 2 0 command-response continuation %s' % first,
-            b'1 2 0 command-response eos %s' % second,
+            b'1 2 0 command-response continuation %s' % second,
+            b'1 2 0 command-response continuation ',
+            b'1 2 0 command-response eos '
         ])
 
     def testservererror(self):
@@ -412,12 +422,15 @@
         self.assertaction(results[0], b'runcommand')
 
         outstream = reactor.makeoutputstream()
-        result = reactor.oncommandresponseready(outstream, 1, b'response')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [b'response'])
         self.assertaction(result, b'noop')
         result = reactor.oninputeof()
         self.assertaction(result, b'sendframes')
         self.assertframesequal(result[1][b'framegen'], [
-            b'1 2 stream-begin command-response eos %sresponse' % OK,
+            b'1 2 stream-begin command-response continuation %s' % OK,
+            b'1 2 0 command-response continuation cbor:b"response"',
+            b'1 2 0 command-response eos ',
         ])
 
     def testmultiplecommanddeferresponse(self):
@@ -427,15 +440,21 @@
         list(sendcommandframes(reactor, instream, 3, b'command2', {}))
 
         outstream = reactor.makeoutputstream()
-        result = reactor.oncommandresponseready(outstream, 1, b'response1')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 1, [b'response1'])
         self.assertaction(result, b'noop')
-        result = reactor.oncommandresponseready(outstream, 3, b'response2')
+        result = reactor.oncommandresponsereadyobjects(
+            outstream, 3, [b'response2'])
         self.assertaction(result, b'noop')
         result = reactor.oninputeof()
         self.assertaction(result, b'sendframes')
         self.assertframesequal(result[1][b'framegen'], [
-            b'1 2 stream-begin command-response eos %sresponse1' % OK,
-            b'3 2 0 command-response eos %sresponse2' % OK,
+            b'1 2 stream-begin command-response continuation %s' % OK,
+            b'1 2 0 command-response continuation cbor:b"response1"',
+            b'1 2 0 command-response eos ',
+            b'3 2 0 command-response continuation %s' % OK,
+            b'3 2 0 command-response continuation cbor:b"response2"',
+            b'3 2 0 command-response eos ',
         ])
 
     def testrequestidtracking(self):
@@ -447,16 +466,22 @@
 
         # Register results for commands out of order.
         outstream = reactor.makeoutputstream()
-        reactor.oncommandresponseready(outstream, 3, b'response3')
-        reactor.oncommandresponseready(outstream, 1, b'response1')
-        reactor.oncommandresponseready(outstream, 5, b'response5')
+        reactor.oncommandresponsereadyobjects(outstream, 3, [b'response3'])
+        reactor.oncommandresponsereadyobjects(outstream, 1, [b'response1'])
+        reactor.oncommandresponsereadyobjects(outstream, 5, [b'response5'])
 
         result = reactor.oninputeof()
         self.assertaction(result, b'sendframes')
         self.assertframesequal(result[1][b'framegen'], [
-            b'3 2 stream-begin command-response eos %sresponse3' % OK,
-            b'1 2 0 command-response eos %sresponse1' % OK,
-            b'5 2 0 command-response eos %sresponse5' % OK,
+            b'3 2 stream-begin command-response continuation %s' % OK,
+            b'3 2 0 command-response continuation cbor:b"response3"',
+            b'3 2 0 command-response eos ',
+            b'1 2 0 command-response continuation %s' % OK,
+            b'1 2 0 command-response continuation cbor:b"response1"',
+            b'1 2 0 command-response eos ',
+            b'5 2 0 command-response continuation %s' % OK,
+            b'5 2 0 command-response continuation cbor:b"response5"',
+            b'5 2 0 command-response eos ',
         ])
 
     def testduplicaterequestonactivecommand(self):
@@ -477,7 +502,7 @@
         instream = framing.stream(1)
         list(sendcommandframes(reactor, instream, 1, b'command1', {}))
         outstream = reactor.makeoutputstream()
-        reactor.oncommandresponseready(outstream, 1, b'response')
+        reactor.oncommandresponsereadyobjects(outstream, 1, [b'response'])
 
         # We've registered the response but haven't sent it. From the
         # perspective of the reactor, the command is still active.
@@ -494,7 +519,7 @@
         instream = framing.stream(1)
         list(sendcommandframes(reactor, instream, 1, b'command1', {}))
         outstream = reactor.makeoutputstream()
-        res = reactor.oncommandresponseready(outstream, 1, b'response')
+        res = reactor.oncommandresponsereadyobjects(outstream, 1, [b'response'])
         list(res[1][b'framegen'])
 
         results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))