def get_and_write(pid, stage_path, poison_pill): def save_file(stage_path, file_path, documents_pid, article_content): logger.debug("\t Salvando arquivo '%s'", file_path) files.write_file(file_path, article_content) files.register_latest_stage(stage_path, documents_pid) if poison_pill.poisoned: return documents_pid = pid.strip() logger.debug("\t coletando dados do Documento '%s'", documents_pid) xml_article = article.ext_article_txt(documents_pid) if xml_article: save_file( stage_path, os.path.join(config.get("SOURCE_PATH"), "%s.xml" % documents_pid), documents_pid, xml_article, ) json_article = article.ext_article_json(documents_pid) if json_article: save_file( stage_path, os.path.join(config.get("SOURCE_PATH"), "%s.json" % documents_pid), documents_pid, json_article, )
def test_ext_article_json(self, mk_ext_article): result = article.ext_article_json("S0036-36341997000100001") mk_ext_article.assert_called_once_with("S0036-36341997000100001")
def test_ext_article_json_returns_none_if_no_ext_article( self, mk_ext_article): mk_ext_article.return_value = None result = article.ext_article_json("S0036-36341997000100001") self.assertIsNone(result)