From 381e3c29fad3de00f6e5be58539b78c29125becf Mon Sep 17 00:00:00 2001 From: Serene-Arc Date: Sun, 18 Jul 2021 14:42:10 +1000 Subject: [PATCH] Fix test where comments in saved list --- tests/test_connector.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_connector.py b/tests/test_connector.py index e561b96..15eede1 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -45,6 +45,15 @@ def assert_all_results_are_submissions(result_limit: int, results: list[Iterator return results +def assert_all_results_are_submissions_or_comments(result_limit: int, results: list[Iterator]) -> list: + results = [sub for res in results for sub in res] + assert all([isinstance(res, praw.models.Submission) or isinstance(res, praw.models.Comment) for res in results]) + assert not any([isinstance(m, MagicMock) for m in results]) + if result_limit is not None: + assert len(results) == result_limit + return results + + def test_determine_directories(tmp_path: Path, downloader_mock: MagicMock): downloader_mock.args.directory = tmp_path / 'test' downloader_mock.config_directories.user_config_dir = tmp_path @@ -297,7 +306,7 @@ def test_get_user_authenticated_lists( downloader_mock.sort_filter = RedditTypes.SortType.HOT downloader_mock.args.user = [RedditConnector.resolve_user_name(downloader_mock, 'me')] results = RedditConnector.get_user_data(downloader_mock) - assert_all_results_are_submissions(10, results) + assert_all_results_are_submissions_or_comments(10, results) @pytest.mark.parametrize(('test_name', 'expected'), (