streaming_test.py 532 Bytes
Newer Older
Guillaume BINET's avatar
Guillaume BINET committed
1
from io import BytesIO
2
from errbot.backends.test import TestPerson
Guillaume BINET's avatar
Guillaume BINET committed
3
from errbot.streaming import Tee
4
from errbot.backends.base import Stream
Guillaume BINET's avatar
Guillaume BINET committed
5 6 7 8 9 10 11 12 13


class StreamingClient(object):
    def callback_stream(self, stream):
        self.response = stream.read()


def test_streaming():
    canary = b'this is my test' * 1000
14
    source = Stream(TestPerson("gbin@gootz.net"), BytesIO(canary))
Guillaume Binet's avatar
Guillaume Binet committed
15
    clients = [StreamingClient() for _ in range(50)]
Guillaume BINET's avatar
Guillaume BINET committed
16 17 18
    Tee(source, clients).run()
    for client in clients:
        assert client.response == canary