From a65e554c551df633382b98b0658c518a2e3ad22d Mon Sep 17 00:00:00 2001 From: Lucas Lavandeira <19612265+lucaslavandeira@users.noreply.github.com> Date: Tue, 11 Dec 2018 11:43:57 -0300 Subject: [PATCH] =?UTF-8?q?Bugfix=20a=20indexaci=C3=B3n=20de=20metadatos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En casos de múltiples catálogos (nodos) cargados, solo el primero tenía sus metadatos indexados de manera correcta. --- .../apps/metadata/indexer/metadata_indexer.py | 2 +- .../apps/metadata/tests/indexer_tests.py | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/series_tiempo_ar_api/apps/metadata/indexer/metadata_indexer.py b/series_tiempo_ar_api/apps/metadata/indexer/metadata_indexer.py index 81e01b53..db716dc4 100644 --- a/series_tiempo_ar_api/apps/metadata/indexer/metadata_indexer.py +++ b/series_tiempo_ar_api/apps/metadata/indexer/metadata_indexer.py @@ -46,7 +46,7 @@ def run(self): IndexMetadataTask.info(self.task, u'Inicio de la indexación de metadatos de {}' .format(node.catalog_id)) - index_created = index_created or CatalogMetadataIndexer(node, self.task, index).index() + index_created = CatalogMetadataIndexer(node, self.task, index).index() or index_created IndexMetadataTask.info(self.task, u'Fin de la indexación de metadatos de {}' .format(node.catalog_id)) except Exception as e: diff --git a/series_tiempo_ar_api/apps/metadata/tests/indexer_tests.py b/series_tiempo_ar_api/apps/metadata/tests/indexer_tests.py index 9549a164..4773950f 100644 --- a/series_tiempo_ar_api/apps/metadata/tests/indexer_tests.py +++ b/series_tiempo_ar_api/apps/metadata/tests/indexer_tests.py @@ -46,6 +46,27 @@ def test_index_unavailable_fields(self): self.assertFalse(index_ok) + def test_multiple_catalogs(self): + self._index(catalog_id='test_catalog', + catalog_url='single_distribution.json') + + self._index(catalog_id='other_catalog', + catalog_url='second_single_distribution.json') + + search = Search( + index=fake_index._name, + using=self.elastic + ).filter('term', + catalog_id='test_catalog') + self.assertTrue(search.execute()) + + other_search = Search( + index=fake_index._name, + using=self.elastic + ).filter('term', + catalog_id='other_catalog') + self.assertTrue(other_search.execute()) + def _index(self, catalog_id, catalog_url, set_availables=True): node = Node.objects.create( catalog_id=catalog_id,