Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
128a834841 | ||
|
|
6a392f3e1a | ||
|
|
93127a703c | ||
|
|
e4ddbaf8ae | ||
|
|
ec75058605 | ||
|
|
2b62e5dc5e | ||
|
|
8d7874096e | ||
|
|
99fcab83c8 | ||
|
|
3027bc0579 | ||
|
|
b1b70a4e76 | ||
|
|
de41341d84 | ||
|
|
a03d43b081 | ||
|
|
f60aaade7f | ||
|
|
d3c34086ff | ||
|
|
6b58c9bcf5 | ||
|
|
c2cba1651e | ||
|
|
c1517d5be8 | ||
|
|
088dce712a | ||
|
|
425e880b09 | ||
|
|
62ec78abee | ||
|
|
74277b2afe | ||
|
|
98b0470703 | ||
|
|
eebe7c79bd | ||
|
|
c8b75dcf0e | ||
|
|
d5c3e45edc | ||
|
|
00c239f974 | ||
|
|
c708a588d8 |
27
.github/workflows/run_test.yml
vendored
Normal file
27
.github/workflows/run_test.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Run All UnitTest
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
max-parallel: 4
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7, 3.8]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt -r requirements_test.txt
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
export PYTHONPATH=./
|
||||||
|
pytest --verbose --color=yes
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
pytchat is a lightweight python library to browse youtube livechat without Selenium or BeautifulSoup.
|
pytchat is a lightweight python library to browse youtube livechat without Selenium or BeautifulSoup.
|
||||||
"""
|
"""
|
||||||
__copyright__ = 'Copyright (C) 2019, 2020 taizan-hokuto'
|
__copyright__ = 'Copyright (C) 2019, 2020 taizan-hokuto'
|
||||||
__version__ = '0.4.3'
|
__version__ = '0.4.4'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__author__ = 'taizan-hokuto'
|
__author__ = 'taizan-hokuto'
|
||||||
__author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'
|
__author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
import json
|
import json
|
||||||
|
from datetime import datetime
|
||||||
from pytchat.parser.live import Parser
|
from pytchat.parser.live import Parser
|
||||||
from pytchat.processors.default.processor import DefaultProcessor
|
from pytchat.processors.default.processor import DefaultProcessor
|
||||||
|
|
||||||
|
|
||||||
|
TEST_TIMETSTAMP = 1570678496000000
|
||||||
|
|
||||||
|
|
||||||
|
def get_local_datetime(timestamp):
|
||||||
|
dt = datetime.fromtimestamp(timestamp / 1000000)
|
||||||
|
return dt.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
|
||||||
def test_textmessage(mocker):
|
def test_textmessage(mocker):
|
||||||
'''text message'''
|
'''text message'''
|
||||||
processor = DefaultProcessor()
|
processor = DefaultProcessor()
|
||||||
@@ -20,7 +29,7 @@ def test_textmessage(mocker):
|
|||||||
assert ret.id == "dummy_id"
|
assert ret.id == "dummy_id"
|
||||||
assert ret.message == "dummy_message"
|
assert ret.message == "dummy_message"
|
||||||
assert ret.timestamp == 1570678496000
|
assert ret.timestamp == 1570678496000
|
||||||
assert ret.datetime == "2019-10-10 12:34:56"
|
assert ret.datetime == get_local_datetime(TEST_TIMETSTAMP)
|
||||||
assert ret.author.name == "author_name"
|
assert ret.author.name == "author_name"
|
||||||
assert ret.author.channelId == "author_channel_id"
|
assert ret.author.channelId == "author_channel_id"
|
||||||
assert ret.author.channelUrl == "http://www.youtube.com/channel/author_channel_id"
|
assert ret.author.channelUrl == "http://www.youtube.com/channel/author_channel_id"
|
||||||
@@ -51,7 +60,7 @@ def test_textmessage_replay_member(mocker):
|
|||||||
assert ret.message == "dummy_message"
|
assert ret.message == "dummy_message"
|
||||||
assert ret.messageEx == ["dummy_message"]
|
assert ret.messageEx == ["dummy_message"]
|
||||||
assert ret.timestamp == 1570678496000
|
assert ret.timestamp == 1570678496000
|
||||||
assert ret.datetime == "2019-10-10 12:34:56"
|
assert ret.datetime == get_local_datetime(TEST_TIMETSTAMP)
|
||||||
assert ret.elapsedTime == "1:23:45"
|
assert ret.elapsedTime == "1:23:45"
|
||||||
assert ret.author.name == "author_name"
|
assert ret.author.name == "author_name"
|
||||||
assert ret.author.channelId == "author_channel_id"
|
assert ret.author.channelId == "author_channel_id"
|
||||||
@@ -83,7 +92,7 @@ def test_superchat(mocker):
|
|||||||
assert ret.message == "dummy_message"
|
assert ret.message == "dummy_message"
|
||||||
assert ret.messageEx == ["dummy_message"]
|
assert ret.messageEx == ["dummy_message"]
|
||||||
assert ret.timestamp == 1570678496000
|
assert ret.timestamp == 1570678496000
|
||||||
assert ret.datetime == "2019-10-10 12:34:56"
|
assert ret.datetime == get_local_datetime(TEST_TIMETSTAMP)
|
||||||
assert ret.elapsedTime == ""
|
assert ret.elapsedTime == ""
|
||||||
assert ret.amountValue == 800
|
assert ret.amountValue == 800
|
||||||
assert ret.amountString == "¥800"
|
assert ret.amountString == "¥800"
|
||||||
@@ -125,7 +134,7 @@ def test_supersticker(mocker):
|
|||||||
assert ret.message == ""
|
assert ret.message == ""
|
||||||
assert ret.messageEx == []
|
assert ret.messageEx == []
|
||||||
assert ret.timestamp == 1570678496000
|
assert ret.timestamp == 1570678496000
|
||||||
assert ret.datetime == "2019-10-10 12:34:56"
|
assert ret.datetime == get_local_datetime(TEST_TIMETSTAMP)
|
||||||
assert ret.elapsedTime == ""
|
assert ret.elapsedTime == ""
|
||||||
assert ret.amountValue == 200
|
assert ret.amountValue == 200
|
||||||
assert ret.amountString == "¥200"
|
assert ret.amountString == "¥200"
|
||||||
@@ -166,7 +175,7 @@ def test_sponsor(mocker):
|
|||||||
assert ret.message == "新規メンバー"
|
assert ret.message == "新規メンバー"
|
||||||
assert ret.messageEx == ["新規メンバー"]
|
assert ret.messageEx == ["新規メンバー"]
|
||||||
assert ret.timestamp == 1570678496000
|
assert ret.timestamp == 1570678496000
|
||||||
assert ret.datetime == "2019-10-10 12:34:56"
|
assert ret.datetime == get_local_datetime(TEST_TIMETSTAMP)
|
||||||
assert ret.elapsedTime == ""
|
assert ret.elapsedTime == ""
|
||||||
assert ret.bgColor == 0
|
assert ret.bgColor == 0
|
||||||
assert ret.author.name == "author_name"
|
assert ret.author.name == "author_name"
|
||||||
@@ -199,7 +208,7 @@ def test_sponsor_legacy(mocker):
|
|||||||
assert ret.message == "新規メンバー / ようこそ、author_name!"
|
assert ret.message == "新規メンバー / ようこそ、author_name!"
|
||||||
assert ret.messageEx == ["新規メンバー / ようこそ、author_name!"]
|
assert ret.messageEx == ["新規メンバー / ようこそ、author_name!"]
|
||||||
assert ret.timestamp == 1570678496000
|
assert ret.timestamp == 1570678496000
|
||||||
assert ret.datetime == "2019-10-10 12:34:56"
|
assert ret.datetime == get_local_datetime(TEST_TIMETSTAMP)
|
||||||
assert ret.elapsedTime == ""
|
assert ret.elapsedTime == ""
|
||||||
assert ret.bgColor == 0
|
assert ret.bgColor == 0
|
||||||
assert ret.author.name == "author_name"
|
assert ret.author.name == "author_name"
|
||||||
|
|||||||
Reference in New Issue
Block a user