mirror of https://github.com/scrapy/scrapy.git
Added test case to make sure that ambiguous clickdata is not allowed
This commit is contained in:
parent
eb47849c05
commit
df2e795278
|
|
@ -5,6 +5,7 @@ from cStringIO import StringIO
|
|||
from urlparse import urlparse
|
||||
|
||||
from scrapy.http import Request, FormRequest, XmlRpcRequest, Headers, HtmlResponse
|
||||
from scrapy.http.request.form import MultipleElementsFound
|
||||
|
||||
|
||||
class RequestTest(unittest.TestCase):
|
||||
|
|
@ -320,6 +321,21 @@ class FormRequestTest(RequestTest):
|
|||
self.assertFalse('clickeable1' in urlargs, urlargs)
|
||||
self.assertFalse('clickeable2' in urlargs, urlargs)
|
||||
|
||||
def test_from_response_ambiguous_clickdata(self):
|
||||
respbody = """
|
||||
<form action="get.php" method="GET">
|
||||
<input type="submit" name="clickeable1" value="clicked1">
|
||||
<input type="hidden" name="one" value="1">
|
||||
<input type="hidden" name="two" value="3">
|
||||
<input type="submit" name="clickeable2" value="clicked2">
|
||||
</form>
|
||||
"""
|
||||
response = HtmlResponse("http://www.example.com/this/list.html", body=respbody)
|
||||
self.assertRaises(MultipleElementsFound,
|
||||
self.request_class.from_response,
|
||||
response,
|
||||
clickdata={'type': 'submit'})
|
||||
|
||||
def test_from_response_errors_noform(self):
|
||||
respbody = """<html></html>"""
|
||||
response = HtmlResponse("http://www.example.com/lala.html", body=respbody)
|
||||
|
|
|
|||
Loading…
Reference in New Issue