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
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