feat: api to restore soft-deleted component [FC-0076] (#35993)

Adds API to handle restoring soft-deleted library blocks.
This commit is contained in:
Navin Karkera
2024-12-13 23:47:46 +05:30
committed by GitHub
parent f4d110c896
commit 971afe6095
8 changed files with 120 additions and 24 deletions

View File

@@ -306,7 +306,10 @@ def _collections_for_content_object(object_id: UsageKey | LearningContextKey) ->
If the object is in no collections, returns:
{
"collections": {},
"collections": {
"display_name": [],
"key": [],
},
}
"""

View File

@@ -185,3 +185,13 @@ class TestUpdateIndexHandlers(ModuleStoreTestCase, LiveServerTestCase):
meilisearch_client.return_value.index.return_value.delete_document.assert_called_with(
"lborgalib_aproblemproblem1-ca3186e9"
)
# Restore the Library Block
library_api.restore_library_block(problem.usage_key)
meilisearch_client.return_value.index.return_value.update_documents.assert_any_call([doc_problem])
meilisearch_client.return_value.index.return_value.update_documents.assert_any_call(
[{'id': doc_problem['id'], 'collections': {'display_name': [], 'key': []}}]
)
meilisearch_client.return_value.index.return_value.update_documents.assert_any_call(
[{'id': doc_problem['id'], 'tags': {}}]
)