def test_xlsx_write_missing_optional_fields_and_themes(self): with NamedTemporaryFile(suffix='.xlsx') as tempfile: catalog = DataJson( os.path.join(self.SAMPLES_DIR, "minimum_data.json")) catalog.to_xlsx(tempfile.name) written_datajson = DataJson(tempfile.name) written_dataset = written_datajson.datasets[0] written_distribution = written_datajson.distributions[0] self.assertTrue('theme' not in written_dataset) self.assertTrue('field' not in written_distribution)
def test_read_write_both_formats_yields_the_same(self): for suffix in ['xlsx', 'json']: catalog = DataJson( os.path.join(self.SAMPLES_DIR, "catalogo_justicia." + suffix)) catalog.to_json(os.path.join(self.TEMP_DIR, "saved_catalog.json")) catalog.to_xlsx(os.path.join(self.TEMP_DIR, "saved_catalog.xlsx")) catalog_json = DataJson( os.path.join(self.TEMP_DIR, "saved_catalog.xlsx")) catalog_xlsx = DataJson( os.path.join(self.TEMP_DIR, "saved_catalog.xlsx")) self.assertEqual(catalog_json, catalog_xlsx) # la llamada to_xlsx() genera los indices en el catalogo original # aplicarla a los catalogos generados deberÃa dejarlos igual al # original catalog_xlsx.to_xlsx(os.path.join(self.TEMP_DIR, "otro.xlsx")) catalog_json.to_xlsx(os.path.join(self.TEMP_DIR, "otro.xlsx")) self.assertEqual(catalog_json, catalog) self.assertEqual(catalog_xlsx, catalog)