diff --git a/tests/test_default_processor.py b/tests/test_default_processor.py index c0fc5b9..819a6da 100644 --- a/tests/test_default_processor.py +++ b/tests/test_default_processor.py @@ -222,6 +222,60 @@ def test_sponsor_legacy(mocker): assert ret.author.isChatModerator is False +def test_jsonify_list(mocker): + '''lagacy sponsor(membership)''' + processor = DefaultProcessor() + parser = Parser(is_replay=False) + _json = _open_file("tests/testdata/default/superchat.json") + + _, chatdata = parser.parse(parser.get_contents(json.loads(_json))) + data = { + "video_id": "", + "timeout": 7, + "chatdata": chatdata + } + + ret = processor.process([data]).json() + tobe = _open_file("tests/testdata/default/jsonified_list.json") + assert ret == tobe + + +def test_jsonify_item(mocker): + '''lagacy sponsor(membership)''' + processor = DefaultProcessor() + parser = Parser(is_replay=False) + _json = _open_file("tests/testdata/default/superchat.json") + + _, chatdata = parser.parse(parser.get_contents(json.loads(_json))) + data = { + "video_id": "", + "timeout": 7, + "chatdata": chatdata + } + + ret = processor.process([data]).items[0].json() + tobe = _open_file("tests/testdata/default/jsonified_item.json") + assert ret == tobe + + +def test_jsonify_item(mocker): + '''lagacy sponsor(membership)''' + processor = DefaultProcessor() + parser = Parser(is_replay=False) + _json = _open_file("tests/testdata/default/superchat.json") + + _, chatdata = parser.parse(parser.get_contents(json.loads(_json))) + data = { + "video_id": "", + "timeout": 7, + "chatdata": chatdata + } + + ret = processor.process([data]).items[0].json() + tobe = _open_file("tests/testdata/default/jsonified_item.json") + assert ret == tobe + + def _open_file(path): with open(path, mode='r', encoding='utf-8') as f: return f.read() diff --git a/tests/testdata/default/jsonified_item.json b/tests/testdata/default/jsonified_item.json new file mode 100644 index 0000000..e1e0d31 --- /dev/null +++ b/tests/testdata/default/jsonified_item.json @@ -0,0 +1 @@ +{"author": {"badgeUrl": "", "type": "", "isVerified": false, "isChatOwner": false, "isChatSponsor": false, "isChatModerator": false, "channelId": "author_channel_id", "channelUrl": "http://www.youtube.com/channel/author_channel_id", "name": "author_name", "imageUrl": "https://yt3.ggpht.com/------------/AAAAAAAAAAA/AAAAAAAAAAA/xxxxxxxxxxxx/s64-x-x-xx-xx-xx-c0xffffff/photo.jpg"}, "type": "superChat", "id": "dummy_id", "timestamp": 1570678496000, "elapsedTime": "", "datetime": "2019-10-10 12:34:56", "message": "dummy_message", "messageEx": ["dummy_message"], "amountValue": 800.0, "amountString": "¥800", "currency": "JPY", "bgColor": 4280150454, "colors": {"headerBackgroundColor": 4278239141, "headerTextColor": 4278190080, "bodyBackgroundColor": 4280150454, "bodyTextColor": 4278190080, "timestampColor": 2147483648, "authorNameTextColor": 2315255808}} \ No newline at end of file diff --git a/tests/testdata/default/jsonified_list.json b/tests/testdata/default/jsonified_list.json new file mode 100644 index 0000000..3d6fe70 --- /dev/null +++ b/tests/testdata/default/jsonified_list.json @@ -0,0 +1 @@ +[{"author": {"badgeUrl": "", "type": "", "isVerified": false, "isChatOwner": false, "isChatSponsor": false, "isChatModerator": false, "channelId": "author_channel_id", "channelUrl": "http://www.youtube.com/channel/author_channel_id", "name": "author_name", "imageUrl": "https://yt3.ggpht.com/------------/AAAAAAAAAAA/AAAAAAAAAAA/xxxxxxxxxxxx/s64-x-x-xx-xx-xx-c0xffffff/photo.jpg"}, "type": "superChat", "id": "dummy_id", "timestamp": 1570678496000, "elapsedTime": "", "datetime": "2019-10-10 12:34:56", "message": "dummy_message", "messageEx": ["dummy_message"], "amountValue": 800.0, "amountString": "¥800", "currency": "JPY", "bgColor": 4280150454, "colors": {"headerBackgroundColor": 4278239141, "headerTextColor": 4278190080, "bodyBackgroundColor": 4280150454, "bodyTextColor": 4278190080, "timestampColor": 2147483648, "authorNameTextColor": 2315255808}}] \ No newline at end of file