Skip to content

Commit 0547eaf

Browse files
committed
test: modified field in course block index
1 parent d5261be commit 0547eaf

File tree

1 file changed

+22
-14
lines changed
  • openedx/core/djangoapps/content/search/tests

1 file changed

+22
-14
lines changed

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,27 @@ def setUp(self):
6161
# Clear the Meilisearch client to avoid side effects from other tests
6262
api.clear_meilisearch_client()
6363

64+
modified_date = datetime(2024, 5, 6, 7, 8, 9, tzinfo=timezone.utc)
6465
# Create course
65-
self.course = self.store.create_course(
66-
"org1",
67-
"test_course",
68-
"test_run",
69-
self.user_id,
70-
fields={"display_name": "Test Course"},
71-
)
72-
course_access, _ = SearchAccess.objects.get_or_create(context_key=self.course.id)
73-
self.course_block_key = "block-v1:org1+test_course+test_run+type@course+block@course"
74-
75-
# Create XBlocks
76-
self.sequential = self.store.create_child(self.user_id, self.course.location, "sequential", "test_sequential")
66+
with freeze_time(modified_date):
67+
self.course = self.store.create_course(
68+
"org1",
69+
"test_course",
70+
"test_run",
71+
self.user_id,
72+
fields={"display_name": "Test Course"},
73+
)
74+
course_access, _ = SearchAccess.objects.get_or_create(context_key=self.course.id)
75+
self.course_block_key = "block-v1:org1+test_course+test_run+type@course+block@course"
76+
77+
# Create XBlocks
78+
self.sequential = self.store.create_child(
79+
self.user_id,
80+
self.course.location,
81+
"sequential",
82+
"test_sequential"
83+
)
84+
self.store.create_child(self.user_id, self.sequential.location, "vertical", "test_vertical")
7785
self.doc_sequential = {
7886
"id": "block-v1org1test_coursetest_runtypesequentialblocktest_sequential-f702c144",
7987
"type": "course_block",
@@ -90,8 +98,8 @@ def setUp(self):
9098
],
9199
"content": {},
92100
"access_id": course_access.id,
101+
"modified": modified_date.timestamp(),
93102
}
94-
self.store.create_child(self.user_id, self.sequential.location, "vertical", "test_vertical")
95103
self.doc_vertical = {
96104
"id": "block-v1org1test_coursetest_runtypeverticalblocktest_vertical-e76a10a4",
97105
"type": "course_block",
@@ -112,6 +120,7 @@ def setUp(self):
112120
],
113121
"content": {},
114122
"access_id": course_access.id,
123+
"modified": modified_date.timestamp(),
115124
}
116125
# Make sure the CourseOverview for the course is created:
117126
CourseOverview.get_from_id(self.course.id)
@@ -130,7 +139,6 @@ def setUp(self):
130139
self.problem1 = library_api.create_library_block(self.library.key, "problem", "p1")
131140
self.problem2 = library_api.create_library_block(self.library.key, "problem", "p2")
132141
# Update problem1, freezing the date so we can verify modified date serializes correctly.
133-
modified_date = datetime(2024, 5, 6, 7, 8, 9, tzinfo=timezone.utc)
134142
with freeze_time(modified_date):
135143
library_api.set_library_block_olx(self.problem1.usage_key, "<problem />")
136144

0 commit comments

Comments
 (0)