Exemplo n.º 1
0
def test_speed_3(mocker):
    '''test speed calculation with empty data.
    '''
    processor = SpeedCalculator(capacity=30)

    _json = _open_file("tests/testdata/speed/speedtest_empty.json")

    _, chatdata = parser.parse(parser.get_contents(json.loads(_json))[0])
    data = {"video_id": "", "timeout": 10, "chatdata": chatdata}
    ret = processor.process([data])
    assert ret == 0
Exemplo n.º 2
0
def test_speed_1(mocker):
    '''test speed calculation with normal json.
    test json has 15 chatdata, duration is 30 seconds,
    so the speed of chatdata is 30 chats/minute.
    '''

    processor = SpeedCalculator(capacity=30)

    _json = _open_file("tests/testdata/speed/speedtest_normal.json")

    _, chatdata = parser.parse(parser.get_contents(json.loads(_json))[0])
    data = {"video_id": "", "timeout": 10, "chatdata": chatdata}
    ret = processor.process([data])
    assert 30 == ret
Exemplo n.º 3
0
def test_speed_1():
    stream = pytchat.create("Hj-wnLIYKjw",
                            seektime=6000,
                            processor=SpeedCalculator())
    while stream.is_alive():
        speed = stream.get()
        assert speed > 100
        break