コード例 #1
0
 def test_login_passwd(self):
     config = configparser.ConfigParser()
     config.read('test.ini')
     del(config['login']['passwd'])
     with open('test.ini', 'w') as config_file:
         config.write(config_file)
     with self.assertRaises(KeyError):
         spider = ruliweb_spiders.RuliwebSpider(name = 'test',
                 ini_file = 'test.ini')
コード例 #2
0
 def test_file_article_urls_empty(self):
     config = configparser.ConfigParser()
     config.read('test.ini')
     config['crawl']['article_urls'] = ''
     with open('test.ini', 'w') as config_file:
         config.write(config_file)
     with self.assertRaises(AttributeError):
         spider = ruliweb_spiders.RuliwebSpider(name = 'test',
                 ini_file = 'test.ini')
コード例 #3
0
 def test_login_id_empty(self):
     config = configparser.ConfigParser()
     config.read('test.ini')
     config['login']['id'] = ''
     with open('test.ini', 'w') as config_file:
         config.write(config_file)
     with self.assertRaises(AttributeError):
         spider = ruliweb_spiders.RuliwebSpider(name = 'test',
                 ini_file = 'test.ini')
コード例 #4
0
 def test_file_page_number_re(self):
     config = configparser.ConfigParser()
     config.read('test.ini')
     del(config['crawl']['page_number_re'])
     with open('test.ini', 'w') as config_file:
         config.write(config_file)
     with self.assertRaises(KeyError):
         spider = ruliweb_spiders.RuliwebSpider(name = 'test',
                 ini_file = 'test.ini')
コード例 #5
0
 def test_file_output_location(self):
     config = configparser.ConfigParser()
     config.read('test.ini')
     del(config['file']['output_location'])
     with open('test.ini', 'w') as config_file:
         config.write(config_file)
     with self.assertRaises(KeyError):
         spider = ruliweb_spiders.RuliwebSpider(name = 'test',
                 ini_file = 'test.ini')
コード例 #6
0
 def test_debug(self):
     # debug
     config = configparser.ConfigParser()
     config.read('test.ini')
     del(config['debug'])
     with open('test.ini', 'w') as config_file:
         config.write(config_file)
     with self.assertRaises(KeyError):
         spider = ruliweb_spiders.RuliwebSpider(name = 'test',
                 ini_file = 'test.ini')
コード例 #7
0
 def test_ini(self):
     with self.assertRaises(OSError):
         spider = ruliweb_spiders.RuliwebSpider(ini_file = 'dumy.ini')
コード例 #8
0
 def test_start_spider(self):
     mock_response = scrapy.http.Response(url='https://bbs.ruliweb.com')
     spider = ruliweb_spiders.RuliwebSpider(name='test')
     with self.assertRaises(Exception):
         spider.start_spider(mock_response)