Skip to content

Commit fd83bd6

Browse files
fix: minor corrections to units/containers API
1 parent 5750147 commit fd83bd6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

openedx_learning/apps/authoring/containers/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ def get_entities_in_published_container(
481481
cev = container.container_entity.versioning.published
482482
elif isinstance(container, ContainerEntity):
483483
cev = container.versioning.published
484+
else:
485+
raise TypeError(f"Expected ContainerEntity or ContainerEntityMixin; got {type(container)}")
484486
if cev == None:
485487
return None # There is no published version of this container. Should this be an exception?
486488
assert isinstance(cev, ContainerEntityVersion)

openedx_learning/apps/authoring/units/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ def get_components_in_draft_unit(
236236

237237

238238
def get_components_in_published_unit(
239-
unit: Unit | UnitVersion,
239+
unit: Unit,
240240
) -> list[UnitListEntry]:
241241
"""
242242
[ 🛑 UNSTABLE ]
243243
Get the list of entities and their versions in the draft version of the
244244
given container.
245245
"""
246-
assert isinstance(unit, (Unit, UnitVersion))
246+
assert isinstance(unit, Unit)
247247
published_entities = container_api.get_entities_in_published_container(unit)
248248
if published_entities == None:
249249
return None # There is no published version of this unit. Should this be an exception?

tests/openedx_learning/apps/authoring/units/test_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ def test_modify_pinned_component(self):
276276
assert authoring_api.get_components_in_draft_unit(unit) == expected_unit_contents
277277
assert authoring_api.get_components_in_published_unit(unit) == expected_unit_contents
278278

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

322-
323321
def test_next_version_with_different_different_title(self):
324322
"""Test creating a unit version with a different title.
325323

0 commit comments

Comments
 (0)