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,