2021-03-13 23:18:30 +13:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
import praw
|
|
|
|
import pytest
|
|
|
|
|
2021-04-12 19:58:32 +12:00
|
|
|
from bdfr.archive_entry.submission_archive_entry import SubmissionArchiveEntry
|
2021-03-13 23:18:30 +13:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.reddit
|
|
|
|
@pytest.mark.parametrize(('test_submission_id', 'min_comments'), (
|
|
|
|
('m3reby', 27),
|
|
|
|
))
|
|
|
|
def test_get_comments(test_submission_id: str, min_comments: int, reddit_instance: praw.Reddit):
|
|
|
|
test_submission = reddit_instance.submission(id=test_submission_id)
|
2021-04-01 21:37:20 +13:00
|
|
|
test_archive_entry = SubmissionArchiveEntry(test_submission)
|
|
|
|
results = test_archive_entry._get_comments()
|
|
|
|
assert len(results) >= min_comments
|
2021-03-13 23:18:30 +13:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.reddit
|
|
|
|
@pytest.mark.parametrize(('test_submission_id', 'expected_dict'), (
|
2021-04-04 05:25:58 +12:00
|
|
|
('m3reby', {
|
|
|
|
'author': 'sinjen-tos',
|
|
|
|
'id': 'm3reby',
|
|
|
|
'link_flair_text': 'image',
|
2021-05-21 08:47:33 +12:00
|
|
|
'pinned': False,
|
|
|
|
'spoiler': False,
|
|
|
|
'over_18': False,
|
|
|
|
'locked': False,
|
|
|
|
'distinguished': None,
|
|
|
|
'created_utc': 1615583837,
|
|
|
|
'permalink': '/r/australia/comments/m3reby/this_little_guy_fell_out_of_a_tree_and_in_front/'
|
2021-04-04 05:25:58 +12:00
|
|
|
}),
|
2022-07-15 16:22:55 +12:00
|
|
|
# TODO: add deleted user test case
|
2021-03-13 23:18:30 +13:00
|
|
|
))
|
|
|
|
def test_get_post_details(test_submission_id: str, expected_dict: dict, reddit_instance: praw.Reddit):
|
|
|
|
test_submission = reddit_instance.submission(id=test_submission_id)
|
2021-04-01 21:37:20 +13:00
|
|
|
test_archive_entry = SubmissionArchiveEntry(test_submission)
|
2021-03-13 23:18:30 +13:00
|
|
|
test_archive_entry._get_post_details()
|
2021-04-01 21:37:20 +13:00
|
|
|
assert all([test_archive_entry.post_details.get(key) == expected_dict[key] for key in expected_dict.keys()])
|