Skip to content

Commit

Permalink
feat: create_next_version -> create_next_component_version (#215)
Browse files Browse the repository at this point in the history
Since the authoring apps now have their APIs aggregated into the public
openedx_learning.api.authoring module, "create_next_version" will be
ambiguous as soon as we create other versioned things like Units.

I'm including an alias to give more flexibility for switching
edx-platform over.

While this is largely refactoring work, it also effectively adds a new
function to the public API, which is why this commit is marked as "feat".
  • Loading branch information
ormsbee authored Aug 20, 2024
1 parent 466462a commit 1ebc212
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions openedx_learning/api/authoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
from ..apps.authoring.components.api import *
from ..apps.authoring.contents.api import *
from ..apps.authoring.publishing.api import *

# This was renamed after the authoring API refactoring pushed this and other
# app APIs into the openedx_learning.api.authoring module. Here I'm aliasing to
# it's previous name, to make migration a little easier.
create_next_version = create_next_component_version
4 changes: 2 additions & 2 deletions openedx_learning/apps/authoring/components/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"get_or_create_component_type",
"create_component",
"create_component_version",
"create_next_version",
"create_next_component_version",
"create_component_and_version",
"get_component",
"get_component_by_key",
Expand Down Expand Up @@ -109,7 +109,7 @@ def create_component_version(
return component_version


def create_next_version(
def create_next_component_version(
component_pk: int,
/,
title: str,
Expand Down
6 changes: 3 additions & 3 deletions tests/openedx_learning/apps/authoring/components/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_multiple_versions(self):
)

# Two text files, hello.txt and goodbye.txt
version_1 = components_api.create_next_version(
version_1 = components_api.create_next_component_version(
self.problem.pk,
title="Problem Version 1",
content_to_replace={
Expand All @@ -440,7 +440,7 @@ def test_multiple_versions(self):

# This should keep the old value for goodbye.txt, add blank.txt, and set
# hello.txt to be a new value (blank).
version_2 = components_api.create_next_version(
version_2 = components_api.create_next_component_version(
self.problem.pk,
title="Problem Version 2",
content_to_replace={
Expand Down Expand Up @@ -469,7 +469,7 @@ def test_multiple_versions(self):

# Now we're going to set "hello.txt" back to hello_content, but remove
# blank.txt, goodbye.txt, and an unknown "nothere.txt".
version_3 = components_api.create_next_version(
version_3 = components_api.create_next_component_version(
self.problem.pk,
title="Problem Version 3",
content_to_replace={
Expand Down

0 comments on commit 1ebc212

Please sign in to comment.