def test_call_unknown(self): p, t, dmx, mux = self.build_proto() # not expecting a return value: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('method_not_there_for_sure', 0, 'foo')) # expecting a return value: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('method_not_there_for_sure', 1, 'bar')) def check_messages(_result): self.assertEquals(self.messages, [('unknown', 'method_not_there_for_sure', 0, 1, ['foo']), ('unknown', 'method_not_there_for_sure', 0, 1, ['bar'])]) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, []) d = defer.Deferred() d.addCallback(check_messages) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_appcall_error(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2, None))) d.addCallback(wait) d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('error', 1, 'abc'))) d.addCallback(wait) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs[0:1], [(0, 6, 0, ['_result', 2.0, None, 1.0], False)]) self.assertErrorsMatch(msgs[1:], [(0, chunks.MSG_COMMAND, 1, ['_error', 1.0, None, ('NetStream.Failed', 'error')], False)]) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'error', 0, 1, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_appcall_error(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject( 3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2, None))) d.addCallback(wait) d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('error', 1, 'abc'))) d.addCallback(wait) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs[0:1], [(0, 6, 0, ['_result', 2.0, None, 1.0], False)]) self.assertErrorsMatch(msgs[1:], [(0, chunks.MSG_COMMAND, 1, [ '_error', 1.0, None, ('NetStream.Failed', 'error') ], False)]) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'error', 0, 1, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_appcall(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2, None))) d.addCallback(wait) # assuming server gives us stream 1; call echo on that stream d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('echo', 1, 'abc'))) d.addCallback(wait) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, [(0, 6, 0, ['_result', 2.0, None, 1.0], False), (0, 6, 1, ['onEcho', 0.0, 'abc'], False), (0, 6, 1, ['_result', 1.0, 'abc'], False)]) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'echo', 0, 1, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_appcall(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject( 3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2, None))) d.addCallback(wait) # assuming server gives us stream 1; call echo on that stream d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('echo', 1, 'abc'))) d.addCallback(wait) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, [(0, 6, 0, ['_result', 2.0, None, 1.0], False), (0, 6, 1, ['onEcho', 0.0, 'abc'], False), (0, 6, 1, ['_result', 1.0, 'abc'], False)]) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'echo', 0, 1, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_call_unknown(self): p, t, dmx, mux = self.build_proto() # not expecting a return value: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('method_not_there_for_sure', 0, 'foo')) # expecting a return value: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('method_not_there_for_sure', 1, 'bar')) def check_messages(_result): self.assertEquals( self.messages, [('unknown', 'method_not_there_for_sure', 0, 1, ['foo']), ('unknown', 'method_not_there_for_sure', 0, 1, ['bar'])]) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, []) d = defer.Deferred() d.addCallback(check_messages) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_command_simple_after_exception(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('breakdown', 0, 'burn', 'baby', 'burn')) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('foobar', 0, 'foo', 'bar')) d = defer.Deferred() d.addCallback(lambda _: self.assertEquals(self.messages, [('foobar', 0, 1, 0.0, 'foo', 'bar')])) def check_clean_logs(result): # we know the breakdown command handler raises an # exception, so let's clean it so the test can pass, but # verify it was actually logged, and only once, while # cleaning, too self.assertEquals(len(self.flushLoggedErrors(ArtificialError)), 1) return result d.addBoth(check_clean_logs) reactor.callLater(0, d.callback, None) return d
def test_call_raising_error_fatal(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('breakdown3', 0)) def check_messages(_result): self.assertEquals(self.messages, [('!3', 0, 1, ())]) def verify_sent_messages(_result): msgs = muxer_messages(mux) error_tuple = ('Artificially.Failed', 'error') self.assertEquals(len(msgs), 1) msg = msgs[0] self.assertEquals(msg[0:3] + msg[4:], (0, chunks.MSG_COMMAND, 1, False)) args = msg[3] self.assertEquals(len(args), 4) self.assertEquals(args[:3], ['_error', 0.0, None]) self.assertIsInstance(args[3], Object) self.assertEquals((args[3].code, args[3].level), error_tuple) d = defer.Deferred() d.addCallback(check_messages) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertTrue(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_connect_ok(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('connect', 1, Object(app='foobar'))) d = defer.Deferred() def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(len(msgs), 4) self.assertEquals(msgs[0][1:3], (chunks.PROTO_WINDOW_SIZE, 0)) self.assertEquals(msgs[1][1:3], (chunks.PROTO_SET_BANDWIDTH, 0)) self.assertEquals( msgs[2][1:4], (chunks.PROTO_USER_CONTROL, 0, '000000000000'.decode('hex'))) self.assertEquals( msgs[3][1:4], (chunks.MSG_COMMAND, 0, ['_result', 1.0, True, True])) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_waitStatus_unhandled(self): p, t, dmx, mux = self.build_proto() # wait for event with specific code, on message stream 1 d = p.waitStatus(1, info2.code) d.addCallback(self.assertEquals, info2) unhandled = ('unhandled', 0, 2, info1) d.addCallback(lambda _: self.assertEquals(self.messages, [unhandled])) # first event sent on ms_id 2 dmx.inject(3, 0, const.RTMP_COMMAND, 2, encode_amf('onStatus', 0, None, info1)) # ... and the next one, on ms_id 1 dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, info2)) return d
def test_waitStatus(self): p, t, dmx, mux = self.build_proto() # wait for event with specific code d = p.waitStatus(1, info1.code) d.addCallback(self.assertEquals, info1) # then wait for any event on message stream 1 d.addCallback(lambda _: p.waitStatus(1, None)) d.addCallback(self.assertEquals, info2) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, info1)) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, info2)) return d
def test_waitStatus_mixed(self): p, t, dmx, mux = self.build_proto() # wait for event with specific code, on message stream 2 d1 = p.waitStatus(2, info1.code) d1.addCallback(self.assertEquals, info1) # also wait for any event on message stream 1 d2 = p.waitStatus(1, None) d2.addCallback(self.assertEquals, info2) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, info2)) dmx.inject(3, 0, const.RTMP_COMMAND, 2, encode_amf('onStatus', 0, None, info1)) return defer.DeferredList([d1, d2], fireOnOneErrback=1)
def test_waitStatus_unexpected(self): p, t, dmx, mux = self.build_proto() code_other = 'Baz.Code' # wait for event with specific code d = p.waitStatus(1, info1.code) d.addCallback(self.assertEquals, info1) # wait for another even, with some other specific code d.addCallback(lambda _: p.waitStatus(1, code_other)) self.assertFailure(d, UnexpectedStatusError) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, info1)) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, info2)) return d
def test_command_simple(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('foobar', 0, 'foo', 'bar')) d = defer.Deferred() d.addCallback(lambda _: self.assertEquals(self.messages, [( 'foobar', 0, 1, 0.0, 'foo', 'bar')])) reactor.callLater(0, d.callback, None) return d
def test_command_simple(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('foobar', 0, 'foo', 'bar')) d = defer.Deferred() d.addCallback(lambda _: self.assertEquals(self.messages, [('foobar', 0, 1, 0.0, 'foo', 'bar')])) reactor.callLater(0, d.callback, None) return d
def test_call_not_connected_unknown(self): p, t, dmx, mux = self.build_proto() # calling something undefined dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('sure_not_there', 1, None)) d = defer.Deferred() d.addCallback(lambda _: self.assertEquals(len(mux.messages), 0)) d.addCallback(lambda _: self.assertTrue(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_waitStatus_no_code(self): p, t, dmx, mux = self.build_proto() # the following info object lacks 'code' field wrong_info = Object(level='status', desc='description2') # wait for any event d = p.waitStatus(1, None) self.assertFailure(d, ProtocolContractError) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None, wrong_info)) return d
def test_command_simple_after_exception(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('breakdown', 0, 'burn', 'baby', 'burn')) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('foobar', 0, 'foo', 'bar')) d = defer.Deferred() d.addCallback(lambda _: self.assertEquals(self.messages, [( 'foobar', 0, 1, 0.0, 'foo', 'bar')])) def check_clean_logs(result): # we know the breakdown command handler raises an # exception, so let's clean it so the test can pass, but # verify it was actually logged, and only once, while # cleaning, too self.assertEquals(len(self.flushLoggedErrors(ArtificialError)), 1) return result d.addBoth(check_clean_logs) reactor.callLater(0, d.callback, None) return d
def test_call_unknown(self): p, t, dmx, mux, d = self.make_connection() # calling something undefined dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('sure_not_there', 2, None)) d.addCallback(wait) def verify_sent_messages(_result): self.assertEquals(mux.messages, []) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_unexpectedCallError(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('_error', 2, None, 'Surprise!')) d = defer.Deferred() def verify_unexpected(result): self.assertEquals(self.messages, [('_error', 0, 1, 2.0, (None, 'Surprise!'))]) return result d.addCallback(verify_unexpected) reactor.callLater(0, d.callback, None) return d
def make_connection(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('connect', 1, Object(app='foobar'))) d = defer.Deferred() def clear_sent_messages(_result): mux.messages[:] = [] d.addCallback(clear_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) reactor.callLater(0, d.callback, None) return p, t, dmx, mux, d
def test_createStream(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject( 3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2, None))) d.addCallback(wait) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, [(0, 6, 0, ['_result', 2.0, None, 1.0], False)]) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_command_unknown(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('method_not_there_for_sure', 0, 'a', 'rrrr')) d = defer.Deferred() def verify_unknown(result): self.assertEquals(self.messages, [('unk_cmd', 'method_not_there_for_sure', 0, 1, [0.0, 'a', 'rrrr'])]) return result d.addCallback(verify_unknown) reactor.callLater(0, d.callback, None) return d
def test_appcall_not_connected(self): p, t, dmx, mux = self.build_proto() d = defer.Deferred() d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('echo', 1, 'abc'))) d.addCallback(wait) def verify_sent_messages(_result): self.assertEquals(mux.messages, []) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertTrue(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_call_without_return(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('foo', 0, 'a', 'b')) def check_messages(_result): self.assertEquals(self.messages, [('foo', 0, 1, 'a', 'b')]) def verify_sent_messages(_result): self.assertEquals(mux.messages, []) d = defer.Deferred() d.addCallback(check_messages) d.addCallback(verify_sent_messages) reactor.callLater(0, d.callback, None) return d
def test_createStream(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2, None))) d.addCallback(wait) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, [(0, 6, 0, ['_result', 2.0, None, 1.0], False)]) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_createStream_wrong_args(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2))) d.addCallback(wait) def verify_sent_messages(_result): self.assertErrorsMatch(muxer_messages(mux), [(0, chunks.MSG_COMMAND, 0, ['_error', 2.0, None, ('NetStream.Failed', 'error')], False)]) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_createStream_wrong_args(self): p, t, dmx, mux, d = self.make_connection() d.addCallback(lambda _: dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 2))) d.addCallback(wait) def verify_sent_messages(_result): self.assertErrorsMatch(muxer_messages(mux), [(0, chunks.MSG_COMMAND, 0, [ '_error', 2.0, None, ('NetStream.Failed', 'error') ], False)]) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_call_with_implicit_none_return(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('bar', 1)) def check_messages(_result): self.assertEquals(self.messages, [('bar', 0, 1, ())]) def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, [(0, 6, 1, ['_result', 1.0, None], False)]) d = defer.Deferred() d.addCallback(check_messages) d.addCallback(verify_sent_messages) reactor.callLater(0, d.callback, None) return d
def test_call_aborted(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('breakdown4', 1)) def check_messages(_result): self.assertEquals(self.messages, [('!4', 0, 1, ())]) def verify_sent_messages(_result): self.assertEquals(mux.messages, []) d = defer.Deferred() d.addCallback(check_messages) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_call_not_connected_createStream(self): p, t, dmx, mux = self.build_proto() # calling something that's definitely supported dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('createStream', 1, None)) d = defer.Deferred() def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(msgs, []) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertTrue(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_appcall_stream_0(self): p, t, dmx, mux, d = self.make_connection() # call defined custom 'echo', on msg stream 0 dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('echo', 2, 'abc')) d.addCallback(wait) def verify_sent_messages(_result): self.assertEquals(mux.messages, []) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'echo', 0, 0, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_connect_fail_bad_args(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('connect', 1)) d = defer.Deferred() def verify_sent_messages(_result): self.assertErrorsMatch( muxer_messages(mux), [(0, chunks.MSG_COMMAND, 0, [ '_error', 1.0, None, ('NetConnection.Connect.Failed', 'error') ], False)]) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertTrue(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_callRemote_result(self): p, t, dmx, mux = self.build_proto() d = p.callRemote(1, 'echo', 'sing it back') self.assertEquals(len(mux.messages), 1) msg = mux.messages[0] self.assertEquals(msg[0:3] + msg[4:], (0, chunks.MSG_COMMAND, 1, False)) # can't rely on transaction number, so we skip it decoded = decode_amf(vb(msg[3])) self.assertEquals((decoded[0], decoded[2]), ('echo', 'sing it back')) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('_result', decoded[1], None, decoded[2])) d.addCallback(self.assertEquals, (None, 'sing it back')) return d
def test_connect_fail_programmer_error(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('connect', 1, Object(app='fail'))) d = defer.Deferred() def verify_sent_messages(_result): self.assertErrorsMatch(muxer_messages(mux), [(0, chunks.MSG_COMMAND, 0, ['_error', 1.0, None, ('NetConnection.Connect.Failed', 'error')], False)]) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertTrue(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_callRemote_error(self): p, t, dmx, mux = self.build_proto() d = p.callRemote(1, 'echo', 'sing it back') self.assertEquals(len(mux.messages), 1) msg = mux.messages[0] self.assertEquals(msg[0:3] + msg[4:], (0, chunks.MSG_COMMAND, 1, False)) # can't rely on transaction number, so we skip it decoded = decode_amf(vb(msg[3])) self.assertEquals((decoded[0], decoded[2]), ('echo', 'sing it back')) err_info = Object(code='Failed', level='error', desc='no echo method') dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('_error', decoded[1], None, err_info)) self.assertFailure(d, CommandResultError) d.addCallback(lambda r: self.assertEquals(r.args, (None, err_info))) return d
def test_connect_ok(self): p, t, dmx, mux = self.build_proto() dmx.inject(3, 0, const.RTMP_COMMAND, 0, encode_amf('connect', 1, Object(app='foobar'))) d = defer.Deferred() def verify_sent_messages(_result): msgs = muxer_messages(mux) self.assertEquals(len(msgs), 4) self.assertEquals(msgs[0][1:3], (chunks.PROTO_WINDOW_SIZE, 0)) self.assertEquals(msgs[1][1:3], (chunks.PROTO_SET_BANDWIDTH, 0)) self.assertEquals(msgs[2][1:4], (chunks.PROTO_USER_CONTROL, 0, '000000000000'.decode('hex'))) self.assertEquals(msgs[3][1:4], (chunks.MSG_COMMAND, 0, ['_result', 1.0, True, True])) d.addCallback(verify_sent_messages) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) reactor.callLater(0, d.callback, None) return d
def test_appcall_no_stream(self): p, t, dmx, mux, d = self.make_connection() # call defined custom 'echo', on msg stream 1, (which wasn't created) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('echo', 2, 'abc')) d.addCallback(wait) def verify_sent_messages(_result): self.assertErrorsMatch(muxer_messages(mux), [(0, chunks.MSG_COMMAND, 1, [ '_error', 2.0, None, ('NetStream.Failed', 'error') ], False)]) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'echo', 0, 1, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_appcall_no_stream(self): p, t, dmx, mux, d = self.make_connection() # call defined custom 'echo', on msg stream 1, (which wasn't created) dmx.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('echo', 2, 'abc')) d.addCallback(wait) def verify_sent_messages(_result): self.assertErrorsMatch(muxer_messages(mux), [(0, chunks.MSG_COMMAND, 1, ['_error', 2.0, None, ('NetStream.Failed', 'error')], False)]) def verify_protocol_calls(_result): self.assertEquals(self.messages, [('unknown', 'echo', 0, 1, ['abc'])]) d.addCallback(verify_sent_messages) d.addCallback(verify_protocol_calls) d.addCallback(lambda _: self.assertFalse(t.disconnecting)) return d
def test_dispatch_command(self): p, t, d, m = self.build_proto() d.inject(3, 0, const.RTMP_COMMAND, 1, encode_amf('onStatus', 0, None)) self.assertEquals(self.messages, [('command', 0, 1, ['onStatus', 0.0, None])])