##// END OF EJS Templates
tests: add all missing b prefixes in reactor tests...
Augie Fackler -
r37700:cb71e0f9 default
parent child Browse files
Show More
@@ -437,5 +437,7 b' test-username-newline.t'
437 test-verify.t
437 test-verify.t
438 test-websub.t
438 test-websub.t
439 test-win32text.t
439 test-win32text.t
440 test-wireproto-clientreactor.py
440 test-wireproto-framing.py
441 test-wireproto-framing.py
442 test-wireproto-serverreactor.py
441 test-xdg.t
443 test-xdg.t
@@ -28,16 +28,16 b' class SingleSendTests(unittest.TestCase)'
28 reactor = framing.clientreactor(hasmultiplesend=False, buffersends=True)
28 reactor = framing.clientreactor(hasmultiplesend=False, buffersends=True)
29
29
30 request, action, meta = reactor.callcommand(b'foo', {})
30 request, action, meta = reactor.callcommand(b'foo', {})
31 self.assertEqual(request.state, 'pending')
31 self.assertEqual(request.state, b'pending')
32 self.assertEqual(action, 'noop')
32 self.assertEqual(action, b'noop')
33
33
34 action, meta = reactor.flushcommands()
34 action, meta = reactor.flushcommands()
35 self.assertEqual(action, 'sendframes')
35 self.assertEqual(action, b'sendframes')
36
36
37 for frame in meta['framegen']:
37 for frame in meta[b'framegen']:
38 self.assertEqual(request.state, 'sending')
38 self.assertEqual(request.state, b'sending')
39
39
40 self.assertEqual(request.state, 'sent')
40 self.assertEqual(request.state, b'sent')
41
41
42 with self.assertRaisesRegexp(error.ProgrammingError,
42 with self.assertRaisesRegexp(error.ProgrammingError,
43 'cannot issue new commands'):
43 'cannot issue new commands'):
@@ -54,51 +54,51 b' class NoBufferTests(unittest.TestCase):'
54
54
55 request, action, meta = reactor.callcommand(b'command1', {})
55 request, action, meta = reactor.callcommand(b'command1', {})
56 self.assertEqual(request.requestid, 1)
56 self.assertEqual(request.requestid, 1)
57 self.assertEqual(action, 'sendframes')
57 self.assertEqual(action, b'sendframes')
58
58
59 self.assertEqual(request.state, 'pending')
59 self.assertEqual(request.state, b'pending')
60
60
61 for frame in meta['framegen']:
61 for frame in meta[b'framegen']:
62 self.assertEqual(request.state, 'sending')
62 self.assertEqual(request.state, b'sending')
63
63
64 self.assertEqual(request.state, 'sent')
64 self.assertEqual(request.state, b'sent')
65
65
66 action, meta = reactor.flushcommands()
66 action, meta = reactor.flushcommands()
67 self.assertEqual(action, 'noop')
67 self.assertEqual(action, b'noop')
68
68
69 # And we can send another command.
69 # And we can send another command.
70 request, action, meta = reactor.callcommand(b'command2', {})
70 request, action, meta = reactor.callcommand(b'command2', {})
71 self.assertEqual(request.requestid, 3)
71 self.assertEqual(request.requestid, 3)
72 self.assertEqual(action, 'sendframes')
72 self.assertEqual(action, b'sendframes')
73
73
74 for frame in meta['framegen']:
74 for frame in meta[b'framegen']:
75 self.assertEqual(request.state, 'sending')
75 self.assertEqual(request.state, b'sending')
76
76
77 self.assertEqual(request.state, 'sent')
77 self.assertEqual(request.state, b'sent')
78
78
79 class BadFrameRecvTests(unittest.TestCase):
79 class BadFrameRecvTests(unittest.TestCase):
80 def testoddstream(self):
80 def testoddstream(self):
81 reactor = framing.clientreactor()
81 reactor = framing.clientreactor()
82
82
83 action, meta = sendframe(reactor, ffs(b'1 1 0 1 0 foo'))
83 action, meta = sendframe(reactor, ffs(b'1 1 0 1 0 foo'))
84 self.assertEqual(action, 'error')
84 self.assertEqual(action, b'error')
85 self.assertEqual(meta['message'],
85 self.assertEqual(meta[b'message'],
86 'received frame with odd numbered stream ID: 1')
86 b'received frame with odd numbered stream ID: 1')
87
87
88 def testunknownstream(self):
88 def testunknownstream(self):
89 reactor = framing.clientreactor()
89 reactor = framing.clientreactor()
90
90
91 action, meta = sendframe(reactor, ffs(b'1 0 0 1 0 foo'))
91 action, meta = sendframe(reactor, ffs(b'1 0 0 1 0 foo'))
92 self.assertEqual(action, 'error')
92 self.assertEqual(action, b'error')
93 self.assertEqual(meta['message'],
93 self.assertEqual(meta[b'message'],
94 'received frame on unknown stream without beginning '
94 b'received frame on unknown stream without beginning '
95 'of stream flag set')
95 b'of stream flag set')
96
96
97 def testunhandledframetype(self):
97 def testunhandledframetype(self):
98 reactor = framing.clientreactor(buffersends=False)
98 reactor = framing.clientreactor(buffersends=False)
99
99
100 request, action, meta = reactor.callcommand(b'foo', {})
100 request, action, meta = reactor.callcommand(b'foo', {})
101 for frame in meta['framegen']:
101 for frame in meta[b'framegen']:
102 pass
102 pass
103
103
104 with self.assertRaisesRegexp(error.ProgrammingError,
104 with self.assertRaisesRegexp(error.ProgrammingError,
@@ -111,19 +111,19 b' class StreamTests(unittest.TestCase):'
111
111
112 request, action, meta = reactor.callcommand(b'foo', {})
112 request, action, meta = reactor.callcommand(b'foo', {})
113
113
114 self.assertEqual(action, 'sendframes')
114 self.assertEqual(action, b'sendframes')
115 for f in meta['framegen']:
115 for f in meta[b'framegen']:
116 pass
116 pass
117
117
118 action, meta = sendframe(
118 action, meta = sendframe(
119 reactor,
119 reactor,
120 ffs(b'%d 0 stream-begin 4 0 foo' % request.requestid))
120 ffs(b'%d 0 stream-begin 4 0 foo' % request.requestid))
121 self.assertEqual(action, 'responsedata')
121 self.assertEqual(action, b'responsedata')
122
122
123 action, meta = sendframe(
123 action, meta = sendframe(
124 reactor,
124 reactor,
125 ffs(b'%d 0 0 4 eos bar' % request.requestid))
125 ffs(b'%d 0 0 4 eos bar' % request.requestid))
126 self.assertEqual(action, 'responsedata')
126 self.assertEqual(action, b'responsedata')
127
127
128 if __name__ == '__main__':
128 if __name__ == '__main__':
129 import silenttestrunner
129 import silenttestrunner
@@ -62,16 +62,16 b' class ServerReactorTests(unittest.TestCa'
62 stream = framing.stream(1)
62 stream = framing.stream(1)
63 results = list(sendcommandframes(reactor, stream, 1, b'mycommand', {}))
63 results = list(sendcommandframes(reactor, stream, 1, b'mycommand', {}))
64 self.assertEqual(len(results), 1)
64 self.assertEqual(len(results), 1)
65 self.assertaction(results[0], 'runcommand')
65 self.assertaction(results[0], b'runcommand')
66 self.assertEqual(results[0][1], {
66 self.assertEqual(results[0][1], {
67 'requestid': 1,
67 b'requestid': 1,
68 'command': b'mycommand',
68 b'command': b'mycommand',
69 'args': {},
69 b'args': {},
70 'data': None,
70 b'data': None,
71 })
71 })
72
72
73 result = reactor.oninputeof()
73 result = reactor.oninputeof()
74 self.assertaction(result, 'noop')
74 self.assertaction(result, b'noop')
75
75
76 def test1argument(self):
76 def test1argument(self):
77 reactor = makereactor()
77 reactor = makereactor()
@@ -79,12 +79,12 b' class ServerReactorTests(unittest.TestCa'
79 results = list(sendcommandframes(reactor, stream, 41, b'mycommand',
79 results = list(sendcommandframes(reactor, stream, 41, b'mycommand',
80 {b'foo': b'bar'}))
80 {b'foo': b'bar'}))
81 self.assertEqual(len(results), 1)
81 self.assertEqual(len(results), 1)
82 self.assertaction(results[0], 'runcommand')
82 self.assertaction(results[0], b'runcommand')
83 self.assertEqual(results[0][1], {
83 self.assertEqual(results[0][1], {
84 'requestid': 41,
84 b'requestid': 41,
85 'command': b'mycommand',
85 b'command': b'mycommand',
86 'args': {b'foo': b'bar'},
86 b'args': {b'foo': b'bar'},
87 'data': None,
87 b'data': None,
88 })
88 })
89
89
90 def testmultiarguments(self):
90 def testmultiarguments(self):
@@ -93,12 +93,12 b' class ServerReactorTests(unittest.TestCa'
93 results = list(sendcommandframes(reactor, stream, 1, b'mycommand',
93 results = list(sendcommandframes(reactor, stream, 1, b'mycommand',
94 {b'foo': b'bar', b'biz': b'baz'}))
94 {b'foo': b'bar', b'biz': b'baz'}))
95 self.assertEqual(len(results), 1)
95 self.assertEqual(len(results), 1)
96 self.assertaction(results[0], 'runcommand')
96 self.assertaction(results[0], b'runcommand')
97 self.assertEqual(results[0][1], {
97 self.assertEqual(results[0][1], {
98 'requestid': 1,
98 b'requestid': 1,
99 'command': b'mycommand',
99 b'command': b'mycommand',
100 'args': {b'foo': b'bar', b'biz': b'baz'},
100 b'args': {b'foo': b'bar', b'biz': b'baz'},
101 'data': None,
101 b'data': None,
102 })
102 })
103
103
104 def testsimplecommanddata(self):
104 def testsimplecommanddata(self):
@@ -107,13 +107,13 b' class ServerReactorTests(unittest.TestCa'
107 results = list(sendcommandframes(reactor, stream, 1, b'mycommand', {},
107 results = list(sendcommandframes(reactor, stream, 1, b'mycommand', {},
108 util.bytesio(b'data!')))
108 util.bytesio(b'data!')))
109 self.assertEqual(len(results), 2)
109 self.assertEqual(len(results), 2)
110 self.assertaction(results[0], 'wantframe')
110 self.assertaction(results[0], b'wantframe')
111 self.assertaction(results[1], 'runcommand')
111 self.assertaction(results[1], b'runcommand')
112 self.assertEqual(results[1][1], {
112 self.assertEqual(results[1][1], {
113 'requestid': 1,
113 b'requestid': 1,
114 'command': b'mycommand',
114 b'command': b'mycommand',
115 'args': {},
115 b'args': {},
116 'data': b'data!',
116 b'data': b'data!',
117 })
117 })
118
118
119 def testmultipledataframes(self):
119 def testmultipledataframes(self):
@@ -129,13 +129,13 b' class ServerReactorTests(unittest.TestCa'
129 results = list(sendframes(reactor, frames))
129 results = list(sendframes(reactor, frames))
130 self.assertEqual(len(results), 4)
130 self.assertEqual(len(results), 4)
131 for i in range(3):
131 for i in range(3):
132 self.assertaction(results[i], 'wantframe')
132 self.assertaction(results[i], b'wantframe')
133 self.assertaction(results[3], 'runcommand')
133 self.assertaction(results[3], b'runcommand')
134 self.assertEqual(results[3][1], {
134 self.assertEqual(results[3][1], {
135 'requestid': 1,
135 b'requestid': 1,
136 'command': b'mycommand',
136 b'command': b'mycommand',
137 'args': {},
137 b'args': {},
138 'data': b'data1data2data3',
138 b'data': b'data1data2data3',
139 })
139 })
140
140
141 def testargumentanddata(self):
141 def testargumentanddata(self):
@@ -150,32 +150,32 b' class ServerReactorTests(unittest.TestCa'
150 reactor = makereactor()
150 reactor = makereactor()
151 results = list(sendframes(reactor, frames))
151 results = list(sendframes(reactor, frames))
152
152
153 self.assertaction(results[-1], 'runcommand')
153 self.assertaction(results[-1], b'runcommand')
154 self.assertEqual(results[-1][1], {
154 self.assertEqual(results[-1][1], {
155 'requestid': 1,
155 b'requestid': 1,
156 'command': b'command',
156 b'command': b'command',
157 'args': {
157 b'args': {
158 b'key': b'val',
158 b'key': b'val',
159 b'foo': b'bar',
159 b'foo': b'bar',
160 },
160 },
161 'data': b'value1value2',
161 b'data': b'value1value2',
162 })
162 })
163
163
164 def testnewandcontinuation(self):
164 def testnewandcontinuation(self):
165 result = self._sendsingleframe(makereactor(),
165 result = self._sendsingleframe(makereactor(),
166 ffs(b'1 1 stream-begin command-request new|continuation '))
166 ffs(b'1 1 stream-begin command-request new|continuation '))
167 self.assertaction(result, 'error')
167 self.assertaction(result, b'error')
168 self.assertEqual(result[1], {
168 self.assertEqual(result[1], {
169 'message': b'received command request frame with both new and '
169 b'message': b'received command request frame with both new and '
170 b'continuation flags set',
170 b'continuation flags set',
171 })
171 })
172
172
173 def testneithernewnorcontinuation(self):
173 def testneithernewnorcontinuation(self):
174 result = self._sendsingleframe(makereactor(),
174 result = self._sendsingleframe(makereactor(),
175 ffs(b'1 1 stream-begin command-request 0 '))
175 ffs(b'1 1 stream-begin command-request 0 '))
176 self.assertaction(result, 'error')
176 self.assertaction(result, b'error')
177 self.assertEqual(result[1], {
177 self.assertEqual(result[1], {
178 'message': b'received command request frame with neither new nor '
178 b'message': b'received command request frame with neither new nor '
179 b'continuation flags set',
179 b'continuation flags set',
180 })
180 })
181
181
@@ -183,9 +183,9 b' class ServerReactorTests(unittest.TestCa'
183 """Command data frame when not running a command is an error."""
183 """Command data frame when not running a command is an error."""
184 result = self._sendsingleframe(makereactor(),
184 result = self._sendsingleframe(makereactor(),
185 ffs(b'1 1 stream-begin command-data 0 ignored'))
185 ffs(b'1 1 stream-begin command-data 0 ignored'))
186 self.assertaction(result, 'error')
186 self.assertaction(result, b'error')
187 self.assertEqual(result[1], {
187 self.assertEqual(result[1], {
188 'message': b'expected command request frame; got 3',
188 b'message': b'expected command request frame; got 3',
189 })
189 })
190
190
191 def testunexpectedcommanddatareceiving(self):
191 def testunexpectedcommanddatareceiving(self):
@@ -196,10 +196,10 b' class ServerReactorTests(unittest.TestCa'
196 ffs(b'1 1 0 command-data eos ignored'),
196 ffs(b'1 1 0 command-data eos ignored'),
197 ]))
197 ]))
198
198
199 self.assertaction(results[0], 'wantframe')
199 self.assertaction(results[0], b'wantframe')
200 self.assertaction(results[1], 'error')
200 self.assertaction(results[1], b'error')
201 self.assertEqual(results[1][1], {
201 self.assertEqual(results[1][1], {
202 'message': b'received command data frame for request that is not '
202 b'message': b'received command data frame for request that is not '
203 b'expecting data: 1',
203 b'expecting data: 1',
204 })
204 })
205
205
@@ -212,28 +212,28 b' class ServerReactorTests(unittest.TestCa'
212 reactor, ffs(b'1 1 stream-begin command-request new '
212 reactor, ffs(b'1 1 stream-begin command-request new '
213 b"cbor:{b'name': b'command'}")))
213 b"cbor:{b'name': b'command'}")))
214 result = reactor.onbytesresponseready(outstream, 1, b'response1')
214 result = reactor.onbytesresponseready(outstream, 1, b'response1')
215 self.assertaction(result, 'sendframes')
215 self.assertaction(result, b'sendframes')
216 list(result[1]['framegen'])
216 list(result[1][b'framegen'])
217 results.append(self._sendsingleframe(
217 results.append(self._sendsingleframe(
218 reactor, ffs(b'1 1 stream-begin command-request new '
218 reactor, ffs(b'1 1 stream-begin command-request new '
219 b"cbor:{b'name': b'command'}")))
219 b"cbor:{b'name': b'command'}")))
220 result = reactor.onbytesresponseready(outstream, 1, b'response2')
220 result = reactor.onbytesresponseready(outstream, 1, b'response2')
221 self.assertaction(result, 'sendframes')
221 self.assertaction(result, b'sendframes')
222 list(result[1]['framegen'])
222 list(result[1][b'framegen'])
223 results.append(self._sendsingleframe(
223 results.append(self._sendsingleframe(
224 reactor, ffs(b'1 1 stream-begin command-request new '
224 reactor, ffs(b'1 1 stream-begin command-request new '
225 b"cbor:{b'name': b'command'}")))
225 b"cbor:{b'name': b'command'}")))
226 result = reactor.onbytesresponseready(outstream, 1, b'response3')
226 result = reactor.onbytesresponseready(outstream, 1, b'response3')
227 self.assertaction(result, 'sendframes')
227 self.assertaction(result, b'sendframes')
228 list(result[1]['framegen'])
228 list(result[1][b'framegen'])
229
229
230 for i in range(3):
230 for i in range(3):
231 self.assertaction(results[i], 'runcommand')
231 self.assertaction(results[i], b'runcommand')
232 self.assertEqual(results[i][1], {
232 self.assertEqual(results[i][1], {
233 'requestid': 1,
233 b'requestid': 1,
234 'command': b'command',
234 b'command': b'command',
235 'args': {},
235 b'args': {},
236 'data': None,
236 b'data': None,
237 })
237 })
238
238
239 def testconflictingrequestid(self):
239 def testconflictingrequestid(self):
@@ -245,10 +245,10 b' class ServerReactorTests(unittest.TestCa'
245 b"cbor:{b'name': b'command1'}"),
245 b"cbor:{b'name': b'command1'}"),
246 ]))
246 ]))
247
247
248 self.assertaction(results[0], 'wantframe')
248 self.assertaction(results[0], b'wantframe')
249 self.assertaction(results[1], 'error')
249 self.assertaction(results[1], b'error')
250 self.assertEqual(results[1][1], {
250 self.assertEqual(results[1][1], {
251 'message': b'request with ID 1 already received',
251 b'message': b'request with ID 1 already received',
252 })
252 })
253
253
254 def testinterleavedcommands(self):
254 def testinterleavedcommands(self):
@@ -277,25 +277,25 b' class ServerReactorTests(unittest.TestCa'
277 ]))
277 ]))
278
278
279 self.assertEqual([t[0] for t in results], [
279 self.assertEqual([t[0] for t in results], [
280 'wantframe',
280 b'wantframe',
281 'wantframe',
281 b'wantframe',
282 'wantframe',
282 b'wantframe',
283 'wantframe',
283 b'wantframe',
284 'runcommand',
284 b'runcommand',
285 'runcommand',
285 b'runcommand',
286 ])
286 ])
287
287
288 self.assertEqual(results[4][1], {
288 self.assertEqual(results[4][1], {
289 'requestid': 3,
289 b'requestid': 3,
290 'command': 'command3',
290 b'command': b'command3',
291 'args': {b'biz': b'baz', b'key': b'val'},
291 b'args': {b'biz': b'baz', b'key': b'val'},
292 'data': None,
292 b'data': None,
293 })
293 })
294 self.assertEqual(results[5][1], {
294 self.assertEqual(results[5][1], {
295 'requestid': 1,
295 b'requestid': 1,
296 'command': 'command1',
296 b'command': b'command1',
297 'args': {b'foo': b'bar', b'key1': b'val'},
297 b'args': {b'foo': b'bar', b'key1': b'val'},
298 'data': None,
298 b'data': None,
299 })
299 })
300
300
301 def testmissingcommanddataframe(self):
301 def testmissingcommanddataframe(self):
@@ -309,8 +309,8 b' class ServerReactorTests(unittest.TestCa'
309 ]
309 ]
310 results = list(sendframes(makereactor(), frames))
310 results = list(sendframes(makereactor(), frames))
311 self.assertEqual(len(results), 2)
311 self.assertEqual(len(results), 2)
312 self.assertaction(results[0], 'wantframe')
312 self.assertaction(results[0], b'wantframe')
313 self.assertaction(results[1], 'runcommand')
313 self.assertaction(results[1], b'runcommand')
314
314
315 def testmissingcommanddataframeflags(self):
315 def testmissingcommanddataframeflags(self):
316 frames = [
316 frames = [
@@ -320,10 +320,10 b' class ServerReactorTests(unittest.TestCa'
320 ]
320 ]
321 results = list(sendframes(makereactor(), frames))
321 results = list(sendframes(makereactor(), frames))
322 self.assertEqual(len(results), 2)
322 self.assertEqual(len(results), 2)
323 self.assertaction(results[0], 'wantframe')
323 self.assertaction(results[0], b'wantframe')
324 self.assertaction(results[1], 'error')
324 self.assertaction(results[1], b'error')
325 self.assertEqual(results[1][1], {
325 self.assertEqual(results[1][1], {
326 'message': b'command data frame without flags',
326 b'message': b'command data frame without flags',
327 })
327 })
328
328
329 def testframefornonreceivingrequest(self):
329 def testframefornonreceivingrequest(self):
@@ -335,9 +335,9 b' class ServerReactorTests(unittest.TestCa'
335 b"cbor:{b'name': b'command3'}"),
335 b"cbor:{b'name': b'command3'}"),
336 ffs(b'5 1 0 command-data eos ignored'),
336 ffs(b'5 1 0 command-data eos ignored'),
337 ]))
337 ]))
338 self.assertaction(results[2], 'error')
338 self.assertaction(results[2], b'error')
339 self.assertEqual(results[2][1], {
339 self.assertEqual(results[2][1], {
340 'message': b'received frame for request that is not receiving: 5',
340 b'message': b'received frame for request that is not receiving: 5',
341 })
341 })
342
342
343 def testsimpleresponse(self):
343 def testsimpleresponse(self):
@@ -348,8 +348,8 b' class ServerReactorTests(unittest.TestCa'
348
348
349 outstream = reactor.makeoutputstream()
349 outstream = reactor.makeoutputstream()
350 result = reactor.onbytesresponseready(outstream, 1, b'response')
350 result = reactor.onbytesresponseready(outstream, 1, b'response')
351 self.assertaction(result, 'sendframes')
351 self.assertaction(result, b'sendframes')
352 self.assertframesequal(result[1]['framegen'], [
352 self.assertframesequal(result[1][b'framegen'], [
353 b'1 2 stream-begin bytes-response eos response',
353 b'1 2 stream-begin bytes-response eos response',
354 ])
354 ])
355
355
@@ -364,8 +364,8 b' class ServerReactorTests(unittest.TestCa'
364
364
365 outstream = reactor.makeoutputstream()
365 outstream = reactor.makeoutputstream()
366 result = reactor.onbytesresponseready(outstream, 1, first + second)
366 result = reactor.onbytesresponseready(outstream, 1, first + second)
367 self.assertaction(result, 'sendframes')
367 self.assertaction(result, b'sendframes')
368 self.assertframesequal(result[1]['framegen'], [
368 self.assertframesequal(result[1][b'framegen'], [
369 b'1 2 stream-begin bytes-response continuation %s' % first,
369 b'1 2 stream-begin bytes-response continuation %s' % first,
370 b'1 2 0 bytes-response eos %s' % second,
370 b'1 2 0 bytes-response eos %s' % second,
371 ])
371 ])
@@ -377,8 +377,8 b' class ServerReactorTests(unittest.TestCa'
377
377
378 outstream = reactor.makeoutputstream()
378 outstream = reactor.makeoutputstream()
379 result = reactor.onapplicationerror(outstream, 1, b'some message')
379 result = reactor.onapplicationerror(outstream, 1, b'some message')
380 self.assertaction(result, 'sendframes')
380 self.assertaction(result, b'sendframes')
381 self.assertframesequal(result[1]['framegen'], [
381 self.assertframesequal(result[1][b'framegen'], [
382 b'1 2 stream-begin error-response application some message',
382 b'1 2 stream-begin error-response application some message',
383 ])
383 ])
384
384
@@ -389,14 +389,14 b' class ServerReactorTests(unittest.TestCa'
389 results = list(sendcommandframes(reactor, instream, 1, b'mycommand',
389 results = list(sendcommandframes(reactor, instream, 1, b'mycommand',
390 {}))
390 {}))
391 self.assertEqual(len(results), 1)
391 self.assertEqual(len(results), 1)
392 self.assertaction(results[0], 'runcommand')
392 self.assertaction(results[0], b'runcommand')
393
393
394 outstream = reactor.makeoutputstream()
394 outstream = reactor.makeoutputstream()
395 result = reactor.onbytesresponseready(outstream, 1, b'response')
395 result = reactor.onbytesresponseready(outstream, 1, b'response')
396 self.assertaction(result, 'noop')
396 self.assertaction(result, b'noop')
397 result = reactor.oninputeof()
397 result = reactor.oninputeof()
398 self.assertaction(result, 'sendframes')
398 self.assertaction(result, b'sendframes')
399 self.assertframesequal(result[1]['framegen'], [
399 self.assertframesequal(result[1][b'framegen'], [
400 b'1 2 stream-begin bytes-response eos response',
400 b'1 2 stream-begin bytes-response eos response',
401 ])
401 ])
402
402
@@ -408,12 +408,12 b' class ServerReactorTests(unittest.TestCa'
408
408
409 outstream = reactor.makeoutputstream()
409 outstream = reactor.makeoutputstream()
410 result = reactor.onbytesresponseready(outstream, 1, b'response1')
410 result = reactor.onbytesresponseready(outstream, 1, b'response1')
411 self.assertaction(result, 'noop')
411 self.assertaction(result, b'noop')
412 result = reactor.onbytesresponseready(outstream, 3, b'response2')
412 result = reactor.onbytesresponseready(outstream, 3, b'response2')
413 self.assertaction(result, 'noop')
413 self.assertaction(result, b'noop')
414 result = reactor.oninputeof()
414 result = reactor.oninputeof()
415 self.assertaction(result, 'sendframes')
415 self.assertaction(result, b'sendframes')
416 self.assertframesequal(result[1]['framegen'], [
416 self.assertframesequal(result[1][b'framegen'], [
417 b'1 2 stream-begin bytes-response eos response1',
417 b'1 2 stream-begin bytes-response eos response1',
418 b'3 2 0 bytes-response eos response2'
418 b'3 2 0 bytes-response eos response2'
419 ])
419 ])
@@ -432,8 +432,8 b' class ServerReactorTests(unittest.TestCa'
432 reactor.onbytesresponseready(outstream, 5, b'response5')
432 reactor.onbytesresponseready(outstream, 5, b'response5')
433
433
434 result = reactor.oninputeof()
434 result = reactor.oninputeof()
435 self.assertaction(result, 'sendframes')
435 self.assertaction(result, b'sendframes')
436 self.assertframesequal(result[1]['framegen'], [
436 self.assertframesequal(result[1][b'framegen'], [
437 b'3 2 stream-begin bytes-response eos response3',
437 b'3 2 stream-begin bytes-response eos response3',
438 b'1 2 0 bytes-response eos response1',
438 b'1 2 0 bytes-response eos response1',
439 b'5 2 0 bytes-response eos response5',
439 b'5 2 0 bytes-response eos response5',
@@ -446,9 +446,9 b' class ServerReactorTests(unittest.TestCa'
446 list(sendcommandframes(reactor, stream, 1, b'command1', {}))
446 list(sendcommandframes(reactor, stream, 1, b'command1', {}))
447 results = list(sendcommandframes(reactor, stream, 1, b'command1', {}))
447 results = list(sendcommandframes(reactor, stream, 1, b'command1', {}))
448
448
449 self.assertaction(results[0], 'error')
449 self.assertaction(results[0], b'error')
450 self.assertEqual(results[0][1], {
450 self.assertEqual(results[0][1], {
451 'message': b'request with ID 1 is already active',
451 b'message': b'request with ID 1 is already active',
452 })
452 })
453
453
454 def testduplicaterequestonactivecommandnosend(self):
454 def testduplicaterequestonactivecommandnosend(self):
@@ -463,9 +463,9 b' class ServerReactorTests(unittest.TestCa'
463 # perspective of the reactor, the command is still active.
463 # perspective of the reactor, the command is still active.
464
464
465 results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))
465 results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))
466 self.assertaction(results[0], 'error')
466 self.assertaction(results[0], b'error')
467 self.assertEqual(results[0][1], {
467 self.assertEqual(results[0][1], {
468 'message': b'request with ID 1 is already active',
468 b'message': b'request with ID 1 is already active',
469 })
469 })
470
470
471 def testduplicaterequestaftersend(self):
471 def testduplicaterequestaftersend(self):
@@ -475,10 +475,10 b' class ServerReactorTests(unittest.TestCa'
475 list(sendcommandframes(reactor, instream, 1, b'command1', {}))
475 list(sendcommandframes(reactor, instream, 1, b'command1', {}))
476 outstream = reactor.makeoutputstream()
476 outstream = reactor.makeoutputstream()
477 res = reactor.onbytesresponseready(outstream, 1, b'response')
477 res = reactor.onbytesresponseready(outstream, 1, b'response')
478 list(res[1]['framegen'])
478 list(res[1][b'framegen'])
479
479
480 results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))
480 results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))
481 self.assertaction(results[0], 'runcommand')
481 self.assertaction(results[0], b'runcommand')
482
482
483 if __name__ == '__main__':
483 if __name__ == '__main__':
484 import silenttestrunner
484 import silenttestrunner
General Comments 0
You need to be logged in to leave comments. Login now