Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ids are longer than expected #783

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bdfr/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def download(self):
def get_submissions_from_link(self) -> list[list[praw.models.Submission]]:
supplied_submissions = []
for sub_id in self.args.link:
if len(sub_id) == 6:
if len(sub_id) in (6, 7):
supplied_submissions.append(self.reddit_instance.submission(id=sub_id))
elif re.match(r"^\w{7}$", sub_id):
supplied_submissions.append(self.reddit_instance.comment(id=sub_id))
Expand Down
17 changes: 17 additions & 0 deletions tests/test_archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@ def test_write_submission_json(test_submission_id: str, tmp_path: Path, test_for
test_submission = reddit_instance.submission(id=test_submission_id)
archiver_mock.file_name_formatter.format_path.return_value = test_path
Archiver.write_entry(archiver_mock, test_submission)

@pytest.mark.online
@pytest.mark.reddit
@pytest.mark.parametrize(
"test_submission_ids",
(
("1000000",),
("https://reddit.com/comments/1000000/"),
),
)
def test_get_submissions_from_link(test_submission_ids: list[str])
archiver_mock = MagicMock()
archiver_mock.args.link = test_submission_ids
results = Archiver.get_submissions_from_link(archiver_mock)
assert all([isinstance(sub, praw.models.Submission) for res in results for sub in res])
assert len(results[0]) == len(test_submission_ids)
assert results[0][0].id == test_submission_ids[0]