add test. fix typos.
This commit is contained in:
parent
dd8d74ee25
commit
2b50ee0724
|
@ -78,7 +78,7 @@ The following options are common between both the `archive` and `download` comma
|
||||||
- Can be specified multiple times
|
- Can be specified multiple times
|
||||||
- Disables certain modules from being used
|
- Disables certain modules from being used
|
||||||
- See [Disabling Modules](#disabling-modules) for more information and a list of module names
|
- See [Disabling Modules](#disabling-modules) for more information and a list of module names
|
||||||
- `--ignore`
|
- `--ignore-user`
|
||||||
- This will add a user to ignore
|
- This will add a user to ignore
|
||||||
- Can be specified multiple times
|
- Can be specified multiple times
|
||||||
- `--include-id-file`
|
- `--include-id-file`
|
||||||
|
|
|
@ -17,7 +17,5 @@ class RedditCloner(RedditDownloader, Archiver):
|
||||||
def download(self):
|
def download(self):
|
||||||
for generator in self.reddit_lists:
|
for generator in self.reddit_lists:
|
||||||
for submission in generator:
|
for submission in generator:
|
||||||
if submission.author.name in self.args.ignore_user:
|
|
||||||
continue
|
|
||||||
self._download_submission(submission)
|
self._download_submission(submission)
|
||||||
self.write_entry(submission)
|
self.write_entry(submission)
|
||||||
|
|
|
@ -51,6 +51,10 @@ class RedditDownloader(RedditConnector):
|
||||||
elif submission.subreddit.display_name.lower() in self.args.skip_subreddit:
|
elif submission.subreddit.display_name.lower() in self.args.skip_subreddit:
|
||||||
logger.debug(f'Submission {submission.id} in {submission.subreddit.display_name} in skip list')
|
logger.debug(f'Submission {submission.id} in {submission.subreddit.display_name} in skip list')
|
||||||
return
|
return
|
||||||
|
elif submission.author.name in self.args.ignore_user:
|
||||||
|
logger.debug(
|
||||||
|
f'Submission {submission.id} in {submission.subreddit.display_name} by {submission.author.name} an ignored user')
|
||||||
|
return
|
||||||
elif not isinstance(submission, praw.models.Submission):
|
elif not isinstance(submission, praw.models.Submission):
|
||||||
logger.warning(f'{submission.id} is not a submission')
|
logger.warning(f'{submission.id} is not a submission')
|
||||||
return
|
return
|
||||||
|
|
|
@ -200,3 +200,20 @@ def test_download_submission(
|
||||||
RedditDownloader._download_submission(downloader_mock, submission)
|
RedditDownloader._download_submission(downloader_mock, submission)
|
||||||
folder_contents = list(tmp_path.iterdir())
|
folder_contents = list(tmp_path.iterdir())
|
||||||
assert len(folder_contents) == expected_files_len
|
assert len(folder_contents) == expected_files_len
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('test_ignore_user', (
|
||||||
|
'alice',
|
||||||
|
))
|
||||||
|
def test_download_ignores_user(
|
||||||
|
test_ignore_user: str,
|
||||||
|
mock_function: MagicMock,
|
||||||
|
downloader_mock: MagicMock,
|
||||||
|
):
|
||||||
|
downloader_mock.args.ignore_user = test_ignore_user
|
||||||
|
submission = downloader_mock.reddit_instance.submission(id='m1hqw6')
|
||||||
|
mock_function.return_value = MagicMock()
|
||||||
|
mock_function.return_value.__name__ = 'test'
|
||||||
|
submission.author.name = test_ignore_user
|
||||||
|
RedditDownloader._download_submission(downloader_mock, submission)
|
||||||
|
assert mock_function.call_count == 0
|
||||||
|
|
Loading…
Reference in a new issue