Beispiel #1
0
    def testdataexactframesize(self):
        data = util.bytesio(b'x' * framing.DEFAULT_MAX_FRAME_SIZE)

        stream = framing.stream(1)
        frames = list(
            framing.createcommandframes(stream, 1, b'command', {}, data))
        self.assertEqual(frames, [
            ffs(b'1 1 stream-begin command-request new|have-data '
                b"cbor:{b'name': b'command'}"),
            ffs(b'1 1 0 command-data continuation %s' % data.getvalue()),
            ffs(b'1 1 0 command-data eos ')
        ])
 def testsimplecommanddata(self):
     reactor = makereactor()
     stream = framing.stream(1)
     results = list(
         sendcommandframes(reactor, stream, 1, b'mycommand', {},
                           util.bytesio(b'data!')))
     self.assertEqual(len(results), 2)
     self.assertaction(results[0], b'wantframe')
     self.assertaction(results[1], b'runcommand')
     self.assertEqual(
         results[1][1], {
             b'requestid': 1,
             b'command': b'mycommand',
             b'args': {},
             b'data': b'data!',
         })
Beispiel #3
0
    def testargsanddata(self):
        data = util.bytesio(b'x' * 100)

        stream = framing.stream(1)
        frames = list(framing.createcommandframes(stream, 1, b'command', {
            b'key1': b'key1value',
            b'key2': b'key2value',
            b'key3': b'key3value',
        }, data))

        self.assertEqual(frames, [
            ffs(b'1 1 stream-begin command-request new|have-data '
                b"cbor:{b'name': b'command', b'args': {b'key1': b'key1value', "
                b"b'key2': b'key2value', b'key3': b'key3value'}}"),
            ffs(b'1 1 0 command-data eos %s' % data.getvalue()),
        ])