diff --git a/openedx_learning/__init__.py b/openedx_learning/__init__.py index a01c57cd0..e718aa232 100644 --- a/openedx_learning/__init__.py +++ b/openedx_learning/__init__.py @@ -1,4 +1,4 @@ """ Open edX Learning ("Learning Core"). """ -__version__ = "0.6.2" +__version__ = "0.6.3" diff --git a/openedx_tagging/core/tagging/api.py b/openedx_tagging/core/tagging/api.py index c416f6f09..d8f2a9786 100644 --- a/openedx_tagging/core/tagging/api.py +++ b/openedx_tagging/core/tagging/api.py @@ -67,6 +67,14 @@ def get_taxonomy(taxonomy_id: int) -> Taxonomy | None: return taxonomy.cast() if taxonomy else None +def get_taxonomy_by_export_id(taxonomy_export_id: str) -> Taxonomy | None: + """ + Returns a Taxonomy cast to the appropriate subclass which has the given export ID. + """ + taxonomy = Taxonomy.objects.filter(export_id=taxonomy_export_id).first() + return taxonomy.cast() if taxonomy else None + + def get_taxonomies(enabled=True) -> QuerySet[Taxonomy]: """ Returns a queryset containing the enabled taxonomies, sorted by name. diff --git a/tests/openedx_tagging/core/tagging/test_api.py b/tests/openedx_tagging/core/tagging/test_api.py index 972159235..51fb3c2f6 100644 --- a/tests/openedx_tagging/core/tagging/test_api.py +++ b/tests/openedx_tagging/core/tagging/test_api.py @@ -88,6 +88,13 @@ def test_get_taxonomy(self) -> None: no_tax = tagging_api.get_taxonomy(200) assert no_tax is None + def test_get_taxonomy_by_export_id(self) -> None: + tax1 = tagging_api.get_taxonomy_by_export_id("life_on_earth") + assert tax1 == self.taxonomy + + no_tax = tagging_api.get_taxonomy_by_export_id("nope") + assert no_tax is None + def test_get_taxonomies(self) -> None: tax1 = tagging_api.create_taxonomy("Enabled") tax2 = tagging_api.create_taxonomy("Disabled", enabled=False)