Skip to content

Commit

Permalink
Fix: tdr_anvils fetch_bundle lacks test coverage (#5046)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Jan 31, 2024
1 parent 08239d1 commit ace67c6
Show file tree
Hide file tree
Showing 3 changed files with 309 additions and 52 deletions.
240 changes: 240 additions & 0 deletions test/indexer/data/826dea02-e274-affe-aabc-eb3db63ad068.tables.tdr.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 23 additions & 16 deletions test/indexer/test_anvil.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
itemgetter,
)
from typing import (
Type,
cast,
)
import unittest
from unittest.mock import (
PropertyMock,
patch,
Expand All @@ -28,6 +28,9 @@
from azul.logging import (
configure_test_logging,
)
from azul.plugins.repository import (
tdr_anvil,
)
from azul.plugins.repository.tdr_anvil import (
BundleEntityType,
TDRAnvilBundle,
Expand All @@ -37,6 +40,9 @@
AnvilCannedBundleTestCase,
IndexerTestCase,
)
from indexer.test_tdr import (
TDRPluginTestCase,
)


# noinspection PyPep8Naming
Expand Down Expand Up @@ -81,7 +87,11 @@ def catalog_config(cls) -> dict[CatalogName, config.Catalog]:
}


class TestAnvilIndexer(AnvilIndexerTestCase):
class TestAnvilIndexer(AnvilIndexerTestCase, TDRPluginTestCase[tdr_anvil.Plugin]):

@classmethod
def _plugin_cls(cls) -> Type[tdr_anvil.Plugin]:
return tdr_anvil.Plugin

def test_indexing(self):
self.maxDiff = None
Expand Down Expand Up @@ -109,6 +119,17 @@ def test_indexing(self):
finally:
self.index_service.delete_indices(self.catalog)

def test_fetch_bundle(self):
canned_bundle = self._load_canned_bundle(self.bundle)
assert isinstance(canned_bundle, TDRAnvilBundle)
self._make_mock_tdr_tables(self.bundle)
plugin = self.plugin_for_source_spec(canned_bundle.fqid.source.spec)
bundle = plugin.fetch_bundle(self.bundle)
assert isinstance(bundle, TDRAnvilBundle)
self.assertEqual(canned_bundle.fqid, bundle.fqid)
self.assertEqual(canned_bundle.entities, bundle.entities)
self.assertEqual(canned_bundle.links, bundle.links)


class TestAnvilIndexerWithIndexesSetUp(AnvilIndexerTestCase):
"""
Expand Down Expand Up @@ -162,17 +183,3 @@ def test_dataset_description(self):
DocumentType.contribution: 2,
**({DocumentType.replica: 2} if config.enable_replicas else {})
})

# FIXME: Enable test after the issue with TinyQuery `WITH` has been resolved
# https://github.com/DataBiosphere/azul/issues/5046
@unittest.skip('TinyQuery does not support the WITH clause')
def test_fetch_bundle(self):
canned_bundle = self._load_canned_bundle(self.bundle)
assert isinstance(canned_bundle, TDRAnvilBundle)
self._make_mock_tdr_tables(self.bundle)
plugin = self.plugin_for_source_spec(canned_bundle.fqid.source.spec)
bundle = plugin.fetch_bundle(self.bundle)
assert isinstance(bundle, TDRAnvilBundle)
self.assertEqual(canned_bundle.fqid, bundle.fqid)
self.assertEqual(canned_bundle.entities, bundle.entities)
self.assertEqual(canned_bundle.links, bundle.links)
Loading

0 comments on commit ace67c6

Please sign in to comment.