From a63b7e1c3e453fd88e280d0877881071697054a0 Mon Sep 17 00:00:00 2001 From: Julia Medina Date: Wed, 12 Mar 2014 07:26:52 -0300 Subject: [PATCH 1/2] 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) From ae4eb90cbfe9d54ffefc7f64151e7f6beea94863 Mon Sep 17 00:00:00 2001 From: Julia Medina Date: Wed, 12 Mar 2014 12:45:46 -0300 Subject: [PATCH 2/2] More appropriate assert in FormRequest test --- scrapy/tests/test_http_request.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrapy/tests/test_http_request.py b/scrapy/tests/test_http_request.py index a386e8617..e438a51ce 100644 --- a/scrapy/tests/test_http_request.py +++ b/scrapy/tests/test_http_request.py @@ -448,8 +448,8 @@ class FormRequestTest(RequestTest): """) 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) + self.assertIn('clickable2', fs) + self.assertNotIn('clickable1', fs) def test_from_response_invalid_nr_index_clickdata(self): response = _buildresponse(