def test_companies_parse_to_csv(self):
     srconf_path = os.path.join(WEB_SOURCES_CONFIG_DIR,
                                'web_statgov_companies.json')
     jobconf_path = os.path.join(JOBS_CONFIG_DIR, 'to_csv.json')
     src_json = Utils.read_file(srconf_path)
     job_json = Utils.read_file(jobconf_path)
     download_handler = HandlersFactory.get_handler(
         Downloader.handler_name(src_json))
     service = Downloader(src_json, download_handler)
     downloaded_file = service.download()
     extract_handler = HandlersFactory.get_handler(
         Extractor.handler_name(src_json))
     service = Extractor(src_json, downloaded_file, self.temp_path,
                         extract_handler)
     service.extract()
     xlspaths = service.path(src_json, self.temp_path)
     parse_handler = HandlersFactory.get_handler(
         XLSParser.handler_name(src_json, job_json))
     service = XLSParser(src_json, job_json, xlspaths, self.data_path,
                         parse_handler)
     csvfile = service.path(src_json, job_json, self.data_path)
     rows_cnt = service.parse()
     self.assertTrue(os.path.exists(csvfile))
     self.assertGreater(rows_cnt, 0)
 def test_wrong_address_to_csv(self):
     srconf_path = os.path.join(WEB_SOURCES_CONFIG_DIR,
                                'web_kgdgov_wrong_address.json')
     jobconf_path = os.path.join(JOBS_CONFIG_DIR, 'to_csv.json')
     src_json = Utils.read_file(srconf_path)
     job_json = Utils.read_file(jobconf_path)
     download_handler = HandlersFactory.get_handler(
         Downloader.handler_name(src_json))
     service = Downloader(src_json, download_handler)
     downloaded_file = service.download()
     parse_handler = HandlersFactory.get_handler(
         XLSParser.handler_name(job_json))
     service = XLSParser(src_json, job_json, downloaded_file,
                         self.data_path, parse_handler)
     csvfile = service.path(src_json, job_json, self.data_path)
     rows_cnt = service.parse()
     self.assertTrue(os.path.exists(csvfile))
     self.assertGreater(rows_cnt, 0)