Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
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')
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
 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')
Ejemplo n.º 10
0
 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')
Ejemplo n.º 11
0
 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')
Ejemplo n.º 12
0
 def test_9(self):
     results = self.html_spider.parse(
         fake_response_from_file('sample3.html'))
     for i in results:
         self.assertEqual(i, {})
Ejemplo n.º 13
0
 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')
Ejemplo n.º 14
0
 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')
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 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, {})
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
 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')
Ejemplo n.º 21
0
 def test_5(self):
     results = self.html_spider.parse(
         fake_response_from_file('sample2.html'))
     self._test_results_count(results, 120)