コード例 #1
0
ファイル: test_component.py プロジェクト: forter/pystorm
    def test_send_message_unicode(self):
        component = Component(input_stream=BytesIO(), output_stream=BytesIO())
        inputs = [{
            "command": "emit",
            "id": 4,
            "stream": "",
            "task": 9,
            "tuple": ["field\uFFE6", 2, 3]
        }, {
            "command": "log",
            "msg": "I am a robot monkey."
        }, {
            "command": "next"
        }, {
            "command": "sync"
        }]
        for cmd in inputs:
            component.serializer.output_stream.close()
            component.serializer.output_stream = component.serializer._wrap_stream(
                BytesIO())
            component.send_message(cmd)
            self.assertEqual(
                component.serializer.serialize_dict(cmd).encode('utf-8'),
                component.serializer.output_stream.buffer.getvalue())

        # Check that we properly skip over invalid input
        self.assertIsNone(component.send_message(['foo', 'bar']))
コード例 #2
0
ファイル: test_component.py プロジェクト: pystorm/pystorm
    def test_send_message_unicode(self):
        component = Component(input_stream=BytesIO(), output_stream=BytesIO())
        inputs = [{"command": "emit", "id": 4, "stream": "", "task": 9,
                   "tuple": ["field\uFFE6", 2, 3]},
                  {"command": "log", "msg": "I am a robot monkey."},
                  {"command": "next"},
                  {"command": "sync"}]
        for cmd in inputs:
            component.serializer.output_stream.close()
            component.serializer.output_stream = component.serializer._wrap_stream(BytesIO())
            component.send_message(cmd)
            self.assertEqual(component.serializer.serialize_dict(cmd).encode('utf-8'),
                             component.serializer.output_stream.buffer.getvalue())

        # Check that we properly skip over invalid input
        self.assertIsNone(component.send_message(['foo', 'bar']))