2021-04-01 21:37:20 +13:00
|
|
|
#!/usr/bin/env python3
|
2022-12-20 12:32:37 +13:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-04-01 21:37:20 +13:00
|
|
|
|
|
|
|
import praw
|
|
|
|
import pytest
|
|
|
|
|
2021-04-12 19:58:32 +12:00
|
|
|
from bdfr.archive_entry.comment_archive_entry import CommentArchiveEntry
|
2021-04-01 21:37:20 +13:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.reddit
|
2022-12-03 18:11:17 +13:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
("test_comment_id", "expected_dict"),
|
|
|
|
(
|
|
|
|
(
|
|
|
|
"gstd4hk",
|
|
|
|
{
|
|
|
|
"author": "james_pic",
|
|
|
|
"subreddit": "Python",
|
|
|
|
"submission": "mgi4op",
|
|
|
|
"submission_title": "76% Faster CPython",
|
|
|
|
"distinguished": None,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
2021-04-01 21:37:20 +13:00
|
|
|
def test_get_comment_details(test_comment_id: str, expected_dict: dict, reddit_instance: praw.Reddit):
|
|
|
|
comment = reddit_instance.comment(id=test_comment_id)
|
|
|
|
test_entry = CommentArchiveEntry(comment)
|
|
|
|
result = test_entry.compile()
|
|
|
|
assert all([result.get(key) == expected_dict[key] for key in expected_dict.keys()])
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.reddit
|
2022-12-03 18:11:17 +13:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
("test_comment_id", "expected_min_comments"),
|
|
|
|
(
|
|
|
|
("gstd4hk", 4),
|
|
|
|
("gsvyste", 3),
|
|
|
|
("gsxnvvb", 5),
|
|
|
|
),
|
|
|
|
)
|
2021-04-01 21:37:20 +13:00
|
|
|
def test_get_comment_replies(test_comment_id: str, expected_min_comments: int, reddit_instance: praw.Reddit):
|
|
|
|
comment = reddit_instance.comment(id=test_comment_id)
|
|
|
|
test_entry = CommentArchiveEntry(comment)
|
|
|
|
result = test_entry.compile()
|
2022-12-03 18:11:17 +13:00
|
|
|
assert len(result.get("replies")) >= expected_min_comments
|