Add informative error when testing user existence
This commit is contained in:
@@ -462,17 +462,46 @@ def test_read_excluded_submission_ids_from_file(downloader_mock: MagicMock, tmp_
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.reddit
|
||||
@pytest.mark.parametrize(('test_redditor_name', 'expected'), (
|
||||
('anthonyhui', True), # Real
|
||||
('lhnhfkuhwreolo', False), # Fake
|
||||
('Bree-Boo', False), # Banned
|
||||
@pytest.mark.parametrize('test_redditor_name', (
|
||||
'Paracortex',
|
||||
'crowdstrike',
|
||||
'HannibalGoddamnit',
|
||||
))
|
||||
def test_check_user_existence(
|
||||
def test_check_user_existence_good(
|
||||
test_redditor_name: str,
|
||||
reddit_instance: praw.Reddit,
|
||||
downloader_mock: MagicMock,
|
||||
):
|
||||
downloader_mock.reddit_instance = reddit_instance
|
||||
RedditDownloader._check_user_existence(downloader_mock, test_redditor_name)
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.reddit
|
||||
@pytest.mark.parametrize('test_redditor_name', (
|
||||
'lhnhfkuhwreolo',
|
||||
'adlkfmnhglojh',
|
||||
))
|
||||
def test_check_user_existence_nonexistent(
|
||||
test_redditor_name: str,
|
||||
expected: bool,
|
||||
reddit_instance: praw.Reddit,
|
||||
downloader_mock: MagicMock,
|
||||
):
|
||||
downloader_mock.reddit_instance = reddit_instance
|
||||
result = RedditDownloader._check_user_existence(downloader_mock, test_redditor_name)
|
||||
assert result == expected
|
||||
with pytest.raises(BulkDownloaderException, match='Could not find'):
|
||||
RedditDownloader._check_user_existence(downloader_mock, test_redditor_name)
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.reddit
|
||||
@pytest.mark.parametrize('test_redditor_name', (
|
||||
'Bree-Boo',
|
||||
))
|
||||
def test_check_user_existence_banned(
|
||||
test_redditor_name: str,
|
||||
reddit_instance: praw.Reddit,
|
||||
downloader_mock: MagicMock,
|
||||
):
|
||||
downloader_mock.reddit_instance = reddit_instance
|
||||
with pytest.raises(BulkDownloaderException, match='is banned'):
|
||||
RedditDownloader._check_user_existence(downloader_mock, test_redditor_name)
|
||||
|
||||
Reference in New Issue
Block a user