From 8db9d0bcc4119d22b3fcb4e6810d737bf981957c Mon Sep 17 00:00:00 2001 From: Serene-Arc Date: Fri, 2 Jul 2021 14:29:39 +1000 Subject: [PATCH] Add test for unauthenticated instances --- bdfr/connector.py | 3 +++ tests/integration_tests/test_download_integration.py | 1 + 2 files changed, 4 insertions(+) diff --git a/bdfr/connector.py b/bdfr/connector.py index 8a6f0bf..a4165fc 100644 --- a/bdfr/connector.py +++ b/bdfr/connector.py @@ -242,6 +242,9 @@ class RedditConnector(metaclass=ABCMeta): if self.args.subreddit: out = [] 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: reddit = self.reddit_instance.subreddit(reddit) try: diff --git a/tests/integration_tests/test_download_integration.py b/tests/integration_tests/test_download_integration.py index 56da1d5..4ee0bba 100644 --- a/tests/integration_tests/test_download_integration.py +++ b/tests/integration_tests/test_download_integration.py @@ -214,6 +214,7 @@ def test_cli_download_long(test_args: list[str], tmp_path: Path): ['--subreddit', 'submitters', '-L', 10], # Private subreddit ['--subreddit', 'donaldtrump', '-L', 10], # Banned subreddit ['--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): runner = CliRunner()