mirror of https://github.com/scrapy/scrapy.git
Improve test coverage
This commit is contained in:
parent
c3178ad694
commit
95928a2f26
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue