From b084cd447d3276f7b1319d557d50a6ef7d3555d9 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Wed, 22 May 2024 12:09:05 -0400 Subject: [PATCH] refactor: create_next_version -> create_next_component_version 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. --- openedx_learning/api/authoring.py | 5 +++++ openedx_learning/apps/authoring/components/api.py | 4 ++-- .../openedx_learning/apps/authoring/components/test_api.py | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/openedx_learning/api/authoring.py b/openedx_learning/api/authoring.py index 749deb99..1da667af 100644 --- a/openedx_learning/api/authoring.py +++ b/openedx_learning/api/authoring.py @@ -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 diff --git a/openedx_learning/apps/authoring/components/api.py b/openedx_learning/apps/authoring/components/api.py index 1839dc8c..d64b507b 100644 --- a/openedx_learning/apps/authoring/components/api.py +++ b/openedx_learning/apps/authoring/components/api.py @@ -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", @@ -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, diff --git a/tests/openedx_learning/apps/authoring/components/test_api.py b/tests/openedx_learning/apps/authoring/components/test_api.py index 7eedffdb..18e5d04d 100644 --- a/tests/openedx_learning/apps/authoring/components/test_api.py +++ b/tests/openedx_learning/apps/authoring/components/test_api.py @@ -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={ @@ -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={ @@ -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={