MCPcopy
hub / github.com/scrapy/scrapy / test_from_response_post

Method test_from_response_post

tests/test_http_request_form.py:112–132  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

110 )
111
112 def test_from_response_post(self):
113 response = _buildresponse(
114 b"""<form action="post.php" method="POST">
115 <input type="hidden" name="test" value="val1">
116 <input type="hidden" name="test" value="val2">
117 <input type="hidden" name="test2" value="xxx">
118 </form>""",
119 url="http://www.example.com/this/list.html",
120 )
121 req = self.request_class.from_response(
122 response, formdata={"one": ["two", "three"], "six": "seven"}
123 )
124
125 assert req.method == "POST"
126 assert req.headers[b"Content-type"] == b"application/x-www-form-urlencoded"
127 assert req.url == "http://www.example.com/this/post.php"
128 fs = _qs(req)
129 assert set(fs[b"test"]) == {b"val1", b"val2"}
130 assert set(fs[b"one"]) == {b"two", b"three"}
131 assert fs[b"test2"] == [b"xxx"]
132 assert fs[b"six"] == [b"seven"]
133
134 def test_from_response_post_nonascii_bytes_utf8(self):
135 response = _buildresponse(

Callers

nothing calls this directly

Calls 3

_buildresponseFunction · 0.85
_qsFunction · 0.85
from_responseMethod · 0.80

Tested by

no test coverage detected