chore: Switch to new openedx-learning import paths (#38004)

Upgrades openedx-learning from 0.31.0 to 0.32.0,
incorporating a major openedx-learning Python API
restructuring: ca0b3eb
This commit is contained in:
Kyle McCormick
2026-02-13 15:39:05 -05:00
committed by GitHub
parent d847d222b2
commit a55c1ddabf
65 changed files with 291 additions and 286 deletions

View File

@@ -25,7 +25,7 @@ from opaque_keys.edx.locator import (
LibraryContainerLocator,
LibraryLocatorV2,
)
from openedx_learning.api import authoring as authoring_api
from openedx_content import api as content_api
from rest_framework.request import Request
from common.djangoapps.student.role_helpers import get_course_roles
@@ -556,7 +556,7 @@ def rebuild_index(status_cb: Callable[[str], None] | None = None, incremental=Fa
# To reduce memory usage on large instances, split up the Collections into pages of 100 collections:
library = lib_api.get_library(lib_key)
collections = authoring_api.get_collections(library.learning_package_id, enabled=True)
collections = content_api.get_collections(library.learning_package_id, enabled=True)
num_collections = collections.count()
num_collections_done = 0
status_cb(f"{num_collections_done}/{num_collections}. Now indexing collections in library {lib_key}")
@@ -572,7 +572,7 @@ def rebuild_index(status_cb: Callable[[str], None] | None = None, incremental=Fa
status_cb(f"{num_collections_done}/{num_collections} collections indexed for library {lib_key}")
# Similarly, batch process Containers (units, sections, etc) in pages of 100
containers = authoring_api.get_containers(library.learning_package_id)
containers = content_api.get_containers(library.learning_package_id)
num_containers = containers.count()
num_containers_done = 0
status_cb(f"{num_containers_done}/{num_containers}. Now indexing containers in library {lib_key}")
@@ -791,7 +791,7 @@ def update_library_components_collections(
"""
library_key = collection_key.lib_key
library = lib_api.get_library(library_key)
components = authoring_api.get_collection_components(
components = content_api.get_collection_components(
library.learning_package_id,
collection_key.collection_id,
)
@@ -827,7 +827,7 @@ def update_library_containers_collections(
"""
library_key = collection_key.lib_key
library = lib_api.get_library(library_key)
containers = authoring_api.get_collection_containers(
containers = content_api.get_collection_containers(
library.learning_package_id,
collection_key.collection_id,
)

View File

@@ -10,8 +10,8 @@ from django.core.exceptions import ObjectDoesNotExist
from django.utils.text import slugify
from opaque_keys.edx.keys import ContainerKey, LearningContextKey, UsageKey, OpaqueKey
from opaque_keys.edx.locator import LibraryCollectionLocator, LibraryContainerLocator
from openedx_learning.api import authoring as authoring_api
from openedx_learning.api.authoring_models import Collection
from openedx_content import api as content_api
from openedx_content.models_api import Collection
from rest_framework.exceptions import NotFound
from openedx.core.djangoapps.content.search.models import SearchAccess
@@ -446,7 +446,7 @@ def searchable_doc_collections(object_id: OpaqueKey) -> dict:
try:
if isinstance(object_id, UsageKey):
component = lib_api.get_component_from_usage_key(object_id)
collections = authoring_api.get_entity_collections(
collections = content_api.get_entity_collections(
component.learning_package_id,
component.key,
).values('key', 'title')
@@ -543,11 +543,11 @@ def searchable_doc_for_collection(
if collection:
assert collection.key == collection_key.collection_id
draft_num_children = authoring_api.filter_publishable_entities(
draft_num_children = content_api.filter_publishable_entities(
collection.entities,
has_draft=True,
).count()
published_num_children = authoring_api.filter_publishable_entities(
published_num_children = content_api.filter_publishable_entities(
collection.entities,
has_published=True,
).count()

View File

@@ -15,7 +15,7 @@ import pytest
from django.test import override_settings
from freezegun import freeze_time
from meilisearch.errors import MeilisearchApiError
from openedx_learning.api import authoring as authoring_api
from openedx_content import api as content_api
from organizations.tests.factories import OrganizationFactory
from common.djangoapps.student.tests.factories import UserFactory
@@ -189,9 +189,9 @@ class TestSearchApi(ModuleStoreTestCase):
tagging_api.add_tag_to_taxonomy(self.taxonomyB, "four")
# Create a collection:
self.learning_package = authoring_api.get_learning_package_by_key(self.library.key)
self.learning_package = content_api.get_learning_package_by_key(self.library.key)
with freeze_time(self.created_date):
self.collection = authoring_api.create_collection(
self.collection = content_api.create_collection(
learning_package_id=self.learning_package.id,
key="MYCOL",
title="my_collection",
@@ -926,7 +926,7 @@ class TestSearchApi(ModuleStoreTestCase):
mock_meilisearch.return_value.index.reset_mock()
# Soft-delete the collection
authoring_api.delete_collection(
content_api.delete_collection(
self.collection.learning_package_id,
self.collection.key,
)
@@ -961,7 +961,7 @@ class TestSearchApi(ModuleStoreTestCase):
# Restore the collection
restored_date = datetime(2023, 8, 9, 10, 11, 12, tzinfo=timezone.utc)
with freeze_time(restored_date):
authoring_api.restore_collection(
content_api.restore_collection(
self.collection.learning_package_id,
self.collection.key,
)
@@ -983,7 +983,7 @@ class TestSearchApi(ModuleStoreTestCase):
mock_meilisearch.return_value.index.reset_mock()
# Hard-delete the collection
authoring_api.delete_collection(
content_api.delete_collection(
self.collection.learning_package_id,
self.collection.key,
hard_delete=True,

View File

@@ -7,7 +7,7 @@ from datetime import datetime, timezone
from freezegun import freeze_time
from opaque_keys.edx.locator import LibraryCollectionLocator, LibraryContainerLocator
from openedx_learning.api import authoring as authoring_api
from openedx_content import api as content_api
from organizations.models import Organization
from openedx.core.djangoapps.content_libraries import api as library_api
@@ -660,7 +660,7 @@ class StudioDocumentsTest(SharedModuleStoreTestCase):
self.container.container_key,
[block_2.usage_key],
user_id=None,
entities_action=authoring_api.ChildrenEntitiesAction.APPEND,
entities_action=content_api.ChildrenEntitiesAction.APPEND,
)
doc = searchable_doc_for_container(self.container.container_key)