File: streaming_test.py

package info (click to toggle)
errbot 6.1.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 3,712 kB
  • sloc: python: 13,831; makefile: 164; sh: 97
file content (19 lines) | stat: -rw-r--r-- 533 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from io import BytesIO

from errbot.backends.base import Stream
from errbot.backends.test import TestPerson
from errbot.streaming import Tee


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


def test_streaming():
    canary = b"this is my test" * 1000
    source = Stream(TestPerson("gbin@gootz.net"), BytesIO(canary))
    clients = [StreamingClient() for _ in range(50)]
    Tee(source, clients).run()
    for client in clients:
        assert client.response == canary