1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-23 13:04:20 +00:00

New tests: clickdata's nr in Formrequest.from_response

This commit is contained in:
Julia Medina 2014-03-12 07:26:52 -03:00
parent 5bbc20f5dd
commit a63b7e1c3e

View File

@ -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(
"""<form>
<input type="submit" name="clickable1" value="clicked1">
<input type="submit" name="clickable2" value="clicked2">
</form>
""")
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(
"""<form>
<input type="submit" name="clickable" value="clicked">
</form>
""")
self.assertRaises(ValueError, self.request_class.from_response,
response, clickdata={'nr': 1})
def test_from_response_errors_noform(self):
response = _buildresponse("""<html></html>""")
self.assertRaises(ValueError, self.request_class.from_response, response)