Пример #1
0
 def probe(self, file: str) -> None:  # pragma: no cover
     config = parse_yaml_file(file)
     self.assertIsInstance(config, dict)
     for crawler_config in config['crawlers']:
         imagecrawler = get_imagecrawler(crawler_config)
         self._probe_crawl(imagecrawler)
         sleep(0.023)  # do not be too greedy
Пример #2
0
 def validate(self, file: str) -> None:
     config = parse_yaml_file(file)
     self.assertIsInstance(config, dict)
     imagecrawlers = list()  # type: List[BaseImageCrawler]
     for crawler_config in config['crawlers']:
         imagecrawler = get_imagecrawler(crawler_config)
         self.assertNotIn(imagecrawler, imagecrawlers, msg='Duplicate ImageCrawler')
         imagecrawlers.append(imagecrawler)
Пример #3
0
 def test_set_optional_loglevel(self) -> None:
     # arrange
     file = realpath(
         path_join(dirname(__file__), 'configs', 'positive',
                   'logging_level_missing.yaml'))
     # act
     config = parse_yaml_file(file)
     # assert
     self.assertEqual(config['logging']['level'], 'INFO')
Пример #4
0
 def test_set_optional_config(self) -> None:
     # arrange
     file = realpath(
         path_join(dirname(__file__), 'configs', 'positive',
                   'crawler_config_missing.yaml'))
     # act
     config = parse_yaml_file(file)
     # assert
     self.assertEqual(len(config["crawlers"]), 1)
     self.assertDictEqual(config["crawlers"][0]["config"], dict())