示例#1
0
 async def test_loop():
     try:
         chat = LiveChatAsync(video_id='__test_id__')
         _ = await chat.get()
         assert chat.is_alive()
         chat.terminate()
         assert not chat.is_alive()
     except ResponseContextError:
         assert False
示例#2
0
def test_Async(*mock):
    vid = '__test_id__'
    _text = _open_file('tests/testdata/paramgen_firstread.json')
    _text = json.loads(_text)
    mock[0].get(f"https://www.youtube.com/live_chat?v={vid}&is_popout=1",
                status=200,
                body=_text)
    try:
        chat = LiveChatAsync(video_id='__test_id__')
        assert chat.is_alive()
        chat.terminate()
        assert not chat.is_alive()
    except ResponseContextError:
        assert not chat.is_alive()
示例#3
0
def test_MultiThread(mocker):
    _text = _open_file('tests/testdata/paramgen_firstread.json')
    _text = json.loads(_text)
    responseMock = mocker.Mock()
    responseMock.status_code = 200
    responseMock.text = _text
    mocker.patch('requests.Session.get').return_value = responseMock
    try:
        chat = LiveChatAsync(video_id='__test_id__')
        assert chat.is_alive()
        chat.terminate()
        assert not chat.is_alive()
    except ResponseContextError:
        chat.terminate()
        assert not chat.is_alive()