Merge pull request #479 from Serene-Arc/bug_fix_146
This commit is contained in:
@@ -242,6 +242,9 @@ class RedditConnector(metaclass=ABCMeta):
|
|||||||
if self.args.subreddit:
|
if self.args.subreddit:
|
||||||
out = []
|
out = []
|
||||||
for reddit in self.split_args_input(self.args.subreddit):
|
for reddit in self.split_args_input(self.args.subreddit):
|
||||||
|
if reddit == 'friends' and self.authenticated is False:
|
||||||
|
logger.error('Cannot read friends subreddit without an authenticated instance')
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
reddit = self.reddit_instance.subreddit(reddit)
|
reddit = self.reddit_instance.subreddit(reddit)
|
||||||
try:
|
try:
|
||||||
@@ -394,7 +397,7 @@ class RedditConnector(metaclass=ABCMeta):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_subreddit_status(subreddit: praw.models.Subreddit):
|
def check_subreddit_status(subreddit: praw.models.Subreddit):
|
||||||
if subreddit.display_name == 'all':
|
if subreddit.display_name in ('all', 'friends'):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
assert subreddit.id
|
assert subreddit.id
|
||||||
|
|||||||
@@ -58,6 +58,21 @@ def test_cli_download_subreddits(test_args: list[str], tmp_path: Path):
|
|||||||
assert 'Added submissions from subreddit ' in result.output
|
assert 'Added submissions from subreddit ' in result.output
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.online
|
||||||
|
@pytest.mark.reddit
|
||||||
|
@pytest.mark.authenticated
|
||||||
|
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
|
||||||
|
@pytest.mark.parametrize('test_args', (
|
||||||
|
['--subreddit', 'friends', '-L', 10, '--authenticate'],
|
||||||
|
))
|
||||||
|
def test_cli_download_user_specific_subreddits(test_args: list[str], tmp_path: Path):
|
||||||
|
runner = CliRunner()
|
||||||
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
||||||
|
result = runner.invoke(cli, test_args)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'Added submissions from subreddit ' in result.output
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
@pytest.mark.reddit
|
@pytest.mark.reddit
|
||||||
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
|
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
|
||||||
@@ -199,6 +214,7 @@ def test_cli_download_long(test_args: list[str], tmp_path: Path):
|
|||||||
['--subreddit', 'submitters', '-L', 10], # Private subreddit
|
['--subreddit', 'submitters', '-L', 10], # Private subreddit
|
||||||
['--subreddit', 'donaldtrump', '-L', 10], # Banned subreddit
|
['--subreddit', 'donaldtrump', '-L', 10], # Banned subreddit
|
||||||
['--user', 'djnish', '--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10],
|
['--user', 'djnish', '--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10],
|
||||||
|
['--subreddit', 'friends', '-L', 10],
|
||||||
))
|
))
|
||||||
def test_cli_download_soft_fail(test_args: list[str], tmp_path: Path):
|
def test_cli_download_soft_fail(test_args: list[str], tmp_path: Path):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|||||||
Reference in New Issue
Block a user