def test_22(self): self._open_xml_results('xml-total-results.txt') html_response_1 = fake_response_from_file('xml_sample.xml') html_response_2 = fake_response_from_file('xml_sample2.xml') nodes = [Selector(html_response_1), Selector(html_response_2)] results = self.xml_spider.parse_several_nodes(html_response_1, nodes) # Test generator for each field for field in results: self._test_xml(results, field)
def test_20(self): html_response_1 = fake_response_from_file('xml_sample.xml') nodes = [Selector(html_response_1)] results = self.xml_spider.parse_several_nodes(html_response_1, nodes) # Test generator for each field for field in results: self._test_xml(results, field)
def test_19(self): html_response = fake_response_from_file('xml_sample3.xml') sel = Selector(html_response) results = self.xml_spider.parse_node(html_response, sel) # Test generator for each field for field in results: self.assertEqual(len(results[field]), 0)
def test_24(self): self._open_xml_results('xml-results2.txt') html_response = fake_response_from_file('xml_sample2.xml') result = self.xml_spider.parse_wb(response=html_response, iterator="html", itertag='title') self.assertNotEqual(result, False) for record in result: for field in record: self._test_xml(record, field)
def test_21(self): html_response_1 = fake_response_from_file('xml_sample.xml') nodes = [] results = self.xml_spider.parse_several_nodes(html_response_1, nodes) self.assertEqual(len(results), 0)
def test_6(self): results = self.html_spider.parse( fake_response_from_file('sample2.html')) self._test_each_field(results, 'result-titles-2.csv', 'Title')
def test_parse(self): for d in self.directorios: results = self.spider.parse( fake_response_from_file('%s%s/index.html' % (self.path, d))) self._test_item_results(results, d) self.spider = balonman.BalonmanSpider(url='a', xornada=0)
def test_27(self): html_response = fake_response_from_file('csv_sample.csv') for row in self.csv_file_results: results = self.csv_spider.parse_row(html_response, row) self.assertEqual(row, results)
def test_16(self): html_response = fake_response_from_file('sample2.html') results = self.crawl_spider.parse(html_response) self._test_each_field(results, 'result-address-2.csv', 'Address')
def test_15(self): html_response = fake_response_from_file('sample2.html') results = self.crawl_spider.parse(html_response) self._test_each_field(results, 'result-titles-2.csv', 'Title')
def test_13(self): html_response = fake_response_from_file('xml_sample.xml') sel = Selector(html_response) results = self.xml_spider.parse_node(html_response, sel) self._test_xml(results, 'price')
def test_9(self): results = self.html_spider.parse( fake_response_from_file('sample3.html')) for i in results: self.assertEqual(i, {})
def test_8(self): results = self.html_spider.parse( fake_response_from_file('sample2.html')) self._test_each_field(results, 'result-address-2.csv', 'Address')
def test_7(self): results = self.html_spider.parse( fake_response_from_file('sample2.html')) self._test_each_field(results, 'result-url-2.csv', 'URL')
def test_25(self): self._open_xml_results('xml-results2.txt') html_response = fake_response_from_file('xml_sample2.xml') result = self.xml_spider.\ parse_wb(response=html_response, iterator="iternodes", itertag='title') self.assertNotEqual(result, False)
def test_26(self): html_response = fake_response_from_file('sample1.html') result = self.xml_spider.parse_wb(response=html_response, iterator="unknowniteratortest") self.assertFalse(result)
def test_17(self): html_response = fake_response_from_file('sample3.html') results = self.crawl_spider.parse(html_response) for i in results: self.assertEqual(i, {})
def test_30(self): html_response = fake_response_from_file('csv_sample_1.csv') # sel = Selector(html_response) results = self.csv_spider.parse_several_rows(html_response) self.assertEqual(len(results), 0)
def test_18(self): html_response = fake_response_from_file('sample2.html') results = self.crawl_spider.parse(html_response) self._test_results_count(results, 120)
def test_parse(self): for d in self.directorios: results = self.spider.parse( fake_response_from_file('%s%s/index.html' % (self.path, d))) self._test_item_results(results, d) self.spider = pnfg.PnfgSpider(url='a')
def test_5(self): results = self.html_spider.parse( fake_response_from_file('sample2.html')) self._test_results_count(results, 120)