Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openedx_learning/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Open edX Learning ("Learning Core").
"""
__version__ = "0.6.2"
__version__ = "0.6.3"
8 changes: 8 additions & 0 deletions openedx_tagging/core/tagging/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions tests/openedx_tagging/core/tagging/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down