5xx error tests
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import prawcore
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
@@ -176,3 +178,30 @@ def test_cli_archive_soft_fail(test_args: list[str], tmp_path: Path):
|
||||
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
|
||||
|
||||
|
||||
@pytest.mark.skipif(not does_test_config_exist, reason="A test config file is required for integration tests")
|
||||
@pytest.mark.parametrize(
|
||||
("test_args", "response"),
|
||||
(
|
||||
(
|
||||
["--user", "nasa", "--submitted"],
|
||||
502,
|
||||
),
|
||||
(
|
||||
["--user", "nasa", "--submitted"],
|
||||
504,
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_user_serv_fail(test_args: list[str], response: int, tmp_path: Path):
|
||||
runner = CliRunner()
|
||||
test_args = create_basic_args_for_archive_runner(test_args, tmp_path)
|
||||
with patch("bdfr.connector.sleep", return_value=None):
|
||||
with patch(
|
||||
"bdfr.connector.RedditConnector.check_user_existence",
|
||||
side_effect=prawcore.exceptions.ResponseException(MagicMock(status_code=response)),
|
||||
):
|
||||
result = runner.invoke(cli, test_args)
|
||||
assert result.exit_code == 0
|
||||
assert f"received {response} HTTP response" in result.output
|
||||
|
||||
Reference in New Issue
Block a user