Skip to content

Commit 31229e2

Browse files
committed
fixup! test: modified field in course block index
1 parent eac4d15 commit 31229e2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

openedx/core/djangoapps/content/search/tests/test_handlers.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def test_create_delete_xblock(self, meilisearch_client):
5959
course_access, _ = SearchAccess.objects.get_or_create(context_key=course.id)
6060

6161
# Create XBlocks
62-
sequential = self.store.create_child(self.user_id, course.location, "sequential", "test_sequential")
62+
created_date = datetime(2023, 4, 5, 6, 7, 8, tzinfo=timezone.utc)
63+
with freeze_time(created_date):
64+
sequential = self.store.create_child(self.user_id, course.location, "sequential", "test_sequential")
6365
doc_sequential = {
6466
"id": "block-v1orgatest_coursetest_runtypesequentialblocktest_sequential-0cdb9395",
6567
"type": "course_block",
@@ -76,10 +78,11 @@ def test_create_delete_xblock(self, meilisearch_client):
7678
],
7779
"content": {},
7880
"access_id": course_access.id,
79-
81+
"modified": created_date.timestamp(),
8082
}
8183
meilisearch_client.return_value.index.return_value.update_documents.assert_called_with([doc_sequential])
82-
vertical = self.store.create_child(self.user_id, sequential.location, "vertical", "test_vertical")
84+
with freeze_time(created_date):
85+
vertical = self.store.create_child(self.user_id, sequential.location, "vertical", "test_vertical")
8386
doc_vertical = {
8487
"id": "block-v1orgatest_coursetest_runtypeverticalblocktest_vertical-011f143b",
8588
"type": "course_block",
@@ -100,18 +103,22 @@ def test_create_delete_xblock(self, meilisearch_client):
100103
],
101104
"content": {},
102105
"access_id": course_access.id,
106+
"modified": created_date.timestamp(),
103107
}
104108

105109
meilisearch_client.return_value.index.return_value.update_documents.assert_called_with([doc_vertical])
106110

107111
# Update the XBlock
108112
sequential = self.store.get_item(sequential.location, self.user_id) # Refresh the XBlock
109113
sequential.display_name = "Updated Sequential"
110-
self.store.update_item(sequential, self.user_id)
114+
modified_date = datetime(2024, 5, 6, 7, 8, 9, tzinfo=timezone.utc)
115+
with freeze_time(modified_date):
116+
self.store.update_item(sequential, self.user_id)
111117

112118
# The display name and the child's breadcrumbs should be updated
113119
doc_sequential["display_name"] = "Updated Sequential"
114120
doc_vertical["breadcrumbs"][1]["display_name"] = "Updated Sequential"
121+
doc_sequential["modified"] = modified_date.timestamp()
115122
meilisearch_client.return_value.index.return_value.update_documents.assert_called_with([
116123
doc_sequential,
117124
doc_vertical,

0 commit comments

Comments
 (0)