From a63b7e1c3e453fd88e280d0877881071697054a0 Mon Sep 17 00:00:00 2001 From: Julia Medina Date: Wed, 12 Mar 2014 07:26:52 -0300 Subject: [PATCH] New tests: clickdata's nr in Formrequest.from_response --- scrapy/tests/test_http_request.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scrapy/tests/test_http_request.py b/scrapy/tests/test_http_request.py index 81b871451..a386e8617 100644 --- a/scrapy/tests/test_http_request.py +++ b/scrapy/tests/test_http_request.py @@ -439,6 +439,27 @@ class FormRequestTest(RequestTest): self.assertRaises(ValueError, self.request_class.from_response, response, clickdata={'nonexistent': 'notme'}) + def test_from_response_nr_index_clickdata(self): + response = _buildresponse( + """
+ + +
+ """) + req = self.request_class.from_response(response, clickdata={'nr': 1}) + fs = _qs(req) + self.assertTrue('clickable2' in fs, fs) + self.assertFalse('clickable1' in fs, fs) + + def test_from_response_invalid_nr_index_clickdata(self): + response = _buildresponse( + """
+ +
+ """) + self.assertRaises(ValueError, self.request_class.from_response, + response, clickdata={'nr': 1}) + def test_from_response_errors_noform(self): response = _buildresponse("""""") self.assertRaises(ValueError, self.request_class.from_response, response)