Fix PRAW deprecations
Fix depreciations in MultiredditHelper and CommentForest.
This commit is contained in:
@@ -32,7 +32,7 @@ class BaseArchiveEntry(ABC):
|
|||||||
'parent_id': in_comment.parent_id,
|
'parent_id': in_comment.parent_id,
|
||||||
'replies': [],
|
'replies': [],
|
||||||
}
|
}
|
||||||
in_comment.replies.replace_more(0)
|
in_comment.replies.replace_more(limit=None)
|
||||||
for reply in in_comment.replies:
|
for reply in in_comment.replies:
|
||||||
out_dict['replies'].append(BaseArchiveEntry._convert_comment_to_dict(reply))
|
out_dict['replies'].append(BaseArchiveEntry._convert_comment_to_dict(reply))
|
||||||
return out_dict
|
return out_dict
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class SubmissionArchiveEntry(BaseArchiveEntry):
|
|||||||
def _get_comments(self) -> list[dict]:
|
def _get_comments(self) -> list[dict]:
|
||||||
logger.debug(f'Retrieving full comment tree for submission {self.source.id}')
|
logger.debug(f'Retrieving full comment tree for submission {self.source.id}')
|
||||||
comments = []
|
comments = []
|
||||||
self.source.comments.replace_more(0)
|
self.source.comments.replace_more(limit=None)
|
||||||
for top_level_comment in self.source.comments:
|
for top_level_comment in self.source.comments:
|
||||||
comments.append(self._convert_comment_to_dict(top_level_comment))
|
comments.append(self._convert_comment_to_dict(top_level_comment))
|
||||||
return comments
|
return comments
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ class RedditConnector(metaclass=ABCMeta):
|
|||||||
out = []
|
out = []
|
||||||
for multi in self.split_args_input(self.args.multireddit):
|
for multi in self.split_args_input(self.args.multireddit):
|
||||||
try:
|
try:
|
||||||
multi = self.reddit_instance.multireddit(self.args.user[0], multi)
|
multi = self.reddit_instance.multireddit(redditor=self.args.user[0], name=multi)
|
||||||
if not multi.subreddits:
|
if not multi.subreddits:
|
||||||
raise errors.BulkDownloaderException
|
raise errors.BulkDownloaderException
|
||||||
out.append(self.create_filtered_listing_generator(multi))
|
out.append(self.create_filtered_listing_generator(multi))
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ def create_basic_args_for_archive_runner(test_args: list[str], run_path: Path):
|
|||||||
['-l', 'gstd4hk'],
|
['-l', 'gstd4hk'],
|
||||||
['-l', 'm2601g', '-f', 'yaml'],
|
['-l', 'm2601g', '-f', 'yaml'],
|
||||||
['-l', 'n60t4c', '-f', 'xml'],
|
['-l', 'n60t4c', '-f', 'xml'],
|
||||||
['-l', 'ijy4ch'], # user deleted post
|
|
||||||
['-l', 'kw4wjm'], # post from banned subreddit
|
|
||||||
))
|
))
|
||||||
def test_cli_archive_single(test_args: list[str], tmp_path: Path):
|
def test_cli_archive_single(test_args: list[str], tmp_path: Path):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
@@ -153,3 +151,18 @@ def test_cli_archive_links_exclusion(test_args: list[str], tmp_path: Path):
|
|||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'in exclusion list' in result.output
|
assert 'in exclusion list' in result.output
|
||||||
assert 'Attempting to archive' not in result.output
|
assert 'Attempting to archive' not in result.output
|
||||||
|
|
||||||
|
@pytest.mark.online
|
||||||
|
@pytest.mark.reddit
|
||||||
|
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
|
||||||
|
@pytest.mark.parametrize('test_args', (
|
||||||
|
['-l', 'ijy4ch'], # user deleted post
|
||||||
|
['-l', 'kw4wjm'], # post from banned subreddit
|
||||||
|
))
|
||||||
|
def test_cli_archive_soft_fail(test_args: list[str], tmp_path: Path):
|
||||||
|
runner = CliRunner()
|
||||||
|
test_args = create_basic_args_for_archive_runner(test_args, tmp_path)
|
||||||
|
result = runner.invoke(cli, test_args)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'failed to be archived due to a PRAW exception' in result.output
|
||||||
|
assert 'Attempting to archive' not in result.output
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ def test_get_multireddits_public(
|
|||||||
downloader_mock.create_filtered_listing_generator.return_value = \
|
downloader_mock.create_filtered_listing_generator.return_value = \
|
||||||
RedditConnector.create_filtered_listing_generator(
|
RedditConnector.create_filtered_listing_generator(
|
||||||
downloader_mock,
|
downloader_mock,
|
||||||
reddit_instance.multireddit(test_user, test_multireddits[0]),
|
reddit_instance.multireddit(redditor=test_user, name=test_multireddits[0]),
|
||||||
)
|
)
|
||||||
results = RedditConnector.get_multireddits(downloader_mock)
|
results = RedditConnector.get_multireddits(downloader_mock)
|
||||||
results = [sub for res in results for sub in res]
|
results = [sub for res in results for sub in res]
|
||||||
|
|||||||
Reference in New Issue
Block a user