diff --git a/tests/test_command_fetch.py b/tests/test_command_fetch.py index df2ee1902..8187c92f0 100644 --- a/tests/test_command_fetch.py +++ b/tests/test_command_fetch.py @@ -38,6 +38,10 @@ class TestFetchCommand: ) assert out.strip() == "Works" + def test_invalid_url(self) -> None: + code, _, _ = proc("fetch", "not-a-url") + assert code != 0 + def test_curl(self, mockserver: MockServer) -> None: url = mockserver.url("/echo") _, out, _ = proc("fetch", "--curl", f"curl -d a=1 -H 'X-Test: foo' {url}") diff --git a/tests/test_command_parse.py b/tests/test_command_parse.py index d12641c45..69240d800 100644 --- a/tests/test_command_parse.py +++ b/tests/test_command_parse.py @@ -225,6 +225,12 @@ ITEM_PIPELINES = {{'{self.project_name}.pipelines.MyPipeline': 1}} ) assert "DEBUG: It Works!" in stderr + def test_invalid_url(self, proj_path: Path) -> None: + code, _, _ = proc( + "parse", "--spider", self.spider_name, "not-a-url", cwd=proj_path + ) + assert code != 0 + def test_curl(self, proj_path: Path, mockserver: MockServer) -> None: _, _, stderr = proc( "parse", diff --git a/tests/test_command_shell.py b/tests/test_command_shell.py index 513474ad8..d2955341d 100644 --- a/tests/test_command_shell.py +++ b/tests/test_command_shell.py @@ -52,6 +52,18 @@ class TestShellCommand: ) assert "('POST', b'a=1')" in out + def test_curl_no_redirect(self, mockserver: MockServer) -> None: + url = mockserver.url("/redirect-no-meta-refresh") + _, out, _ = proc( + "shell", + "--no-redirect", + "--curl", + f"curl {url}", + "-c", + "response.status", + ) + assert out.strip().endswith("302") + def test_curl_with_url(self, mockserver: MockServer) -> None: url = mockserver.url("/echo") code, _, _ = proc("shell", "--curl", f"curl {url}", url, "-c", "url")