Skip to content

Commit

Permalink
fix: minor corrections to units/containers API
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Feb 15, 2025
1 parent 5750147 commit fd83bd6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions openedx_learning/apps/authoring/containers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ def get_entities_in_published_container(
cev = container.container_entity.versioning.published
elif isinstance(container, ContainerEntity):
cev = container.versioning.published
else:
raise TypeError(f"Expected ContainerEntity or ContainerEntityMixin; got {type(container)}")
if cev == None:
return None # There is no published version of this container. Should this be an exception?
assert isinstance(cev, ContainerEntityVersion)
Expand Down
4 changes: 2 additions & 2 deletions openedx_learning/apps/authoring/units/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ def get_components_in_draft_unit(


def get_components_in_published_unit(
unit: Unit | UnitVersion,
unit: Unit,
) -> list[UnitListEntry]:
"""
[ 🛑 UNSTABLE ]
Get the list of entities and their versions in the draft version of the
given container.
"""
assert isinstance(unit, (Unit, UnitVersion))
assert isinstance(unit, Unit)
published_entities = container_api.get_entities_in_published_container(unit)
if published_entities == None:
return None # There is no published version of this unit. Should this be an exception?
Expand Down
2 changes: 0 additions & 2 deletions tests/openedx_learning/apps/authoring/units/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ def test_modify_pinned_component(self):
assert authoring_api.get_components_in_draft_unit(unit) == expected_unit_contents
assert authoring_api.get_components_in_published_unit(unit) == expected_unit_contents


def test_query_count_of_contains_unpublished_changes(self):
"""
Checking for unpublished changes in a unit should require a fixed number
Expand Down Expand Up @@ -319,7 +318,6 @@ def test_query_count_of_contains_unpublished_changes(self):
# Test viewing old snapshots of units and components by passing in a timestamp (or PublishLog PK) to a
# get_historic_unit() API?


def test_next_version_with_different_different_title(self):
"""Test creating a unit version with a different title.
Expand Down

0 comments on commit fd83bd6

Please sign in to comment.