def test_readme_file_write(self): actual_filename = os.path.join(self.TEMP_DIR, "catalog_readme.md") expected_filename = os.path.join(self.RESULTS_DIR, "catalog_readme.md") generate_readme(self.catalog, export_path=actual_filename) comparison = filecmp.cmp(actual_filename, expected_filename) if comparison: os.remove(actual_filename) else: """ {} se escribió correctamente, pero no es idéntico al esperado. Por favor, revíselo manualmente""".format(actual_filename) assert_true(comparison)
def test_generate_readme(self): with io.open(os.path.join(self.RESULTS_DIR, "catalog_readme.md"), 'r', encoding='utf-8') as expected_readme_file: expected_readme = expected_readme_file.read() readme = generate_readme(self.catalog) assert_equal(expected_readme, readme)
def test_readme_null_indicators(self, mock_indicators): mock_indicators.return_value = { 'datasets_federados_cant': None, 'datasets_federados_pct': None, 'datasets_no_federados_cant': None, 'datasets_federados_eliminados_cant': None, 'distribuciones_federadas_cant': None, 'datasets_federados_eliminados': [], 'datasets_no_federados': [], 'datasets_federados': [], } results_path = os.path.join(self.RESULTS_DIR, "null_indicators_readme.md") with io.open(results_path, 'r', encoding='utf-8') \ as expected_readme_file: expected_readme = expected_readme_file.read() readme = generate_readme(self.catalog) assert_equal(expected_readme, readme)