From df2e7952783761e85ce31d867e49531d2831caf2 Mon Sep 17 00:00:00 2001 From: Lucian Ursu Date: Tue, 10 Apr 2012 10:19:59 +0300 Subject: [PATCH] Added test case to make sure that ambiguous clickdata is not allowed --- scrapy/tests/test_http_request.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scrapy/tests/test_http_request.py b/scrapy/tests/test_http_request.py index 8765070cc..091982742 100644 --- a/scrapy/tests/test_http_request.py +++ b/scrapy/tests/test_http_request.py @@ -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 = """ +
+ + + + +
+ """ + 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 = """""" response = HtmlResponse("http://www.example.com/lala.html", body=respbody)