Skip to content

Commit

Permalink
test: fix restore block test case
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Dec 13, 2024
1 parent 19494aa commit 30d335e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,10 @@ def test_create_delete_library_block(self, meilisearch_client):

# Restore the Library Block
library_api.restore_library_block(problem.usage_key)
meilisearch_client.return_value.index.return_value.update_documents.assert_called_with([doc_problem])
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': {}}]
)
2 changes: 0 additions & 2 deletions openedx/core/djangoapps/content_tagging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
XBLOCK_DUPLICATED,
LIBRARY_BLOCK_CREATED,
LIBRARY_BLOCK_UPDATED,
LIBRARY_BLOCK_DELETED,
)

from .api import copy_object_tags
Expand All @@ -30,7 +29,6 @@
update_course_tags,
update_xblock_tags,
update_library_block_tags,
delete_library_block_tags,
)
from .toggles import CONTENT_TAGGING_AUTO

Expand Down
11 changes: 5 additions & 6 deletions openedx/core/djangoapps/content_tagging/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,16 @@ def test_create_delete_restore_library_block(self):
# Check if the tags are created in the Library Block with the user's preferred language
assert self._check_tag(usage_key_str, LANGUAGE_TAXONOMY_ID, 'Português (Brasil)')

# Delete the XBlock
# Soft delete the XBlock
delete_library_block(library_block.usage_key)

# Check if the tags are deleted
assert self._check_tag(usage_key_str, LANGUAGE_TAXONOMY_ID, None)
# Check that the tags are not deleted
assert self._check_tag(usage_key_str, LANGUAGE_TAXONOMY_ID, 'Português (Brasil)')

# Restore the XBlock
with patch('crum.get_current_request', return_value=fake_request):
restore_library_block(library_block.usage_key)
restore_library_block(library_block.usage_key)

# Check if the tags are restored in the Library Block with the user's preferred language
# Check if the tags are still present in the Library Block with the user's preferred language
assert self._check_tag(usage_key_str, LANGUAGE_TAXONOMY_ID, 'Português (Brasil)')

@override_waffle_flag(CONTENT_TAGGING_AUTO, active=False)
Expand Down

0 comments on commit 30d335e

Please sign in to comment.