From 794c78af0856d1284a3fb6960f5c4de834217659 Mon Sep 17 00:00:00 2001 From: Matt Bertrand Date: Wed, 17 Sep 2025 16:48:17 -0400 Subject: [PATCH 1/2] Fix flaky test --- learning_resources/tasks.py | 2 +- learning_resources/tasks_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/learning_resources/tasks.py b/learning_resources/tasks.py index c897ab7086..fe6a064ef0 100644 --- a/learning_resources/tasks.py +++ b/learning_resources/tasks.py @@ -209,7 +209,7 @@ def get_content_tasks( # noqa: PLR0913 if learning_resource_ids: learning_resources = LearningResource.objects.filter( id__in=learning_resource_ids, etl_source=etl_source - ).values_list("id", flat=True) + ).order_by("-id").values_list("id", flat=True) else: learning_resources = ( LearningResource.objects.filter(Q(published=True) | Q(test_mode=True)) diff --git a/learning_resources/tasks_test.py b/learning_resources/tasks_test.py index e489138e7b..ee0d038765 100644 --- a/learning_resources/tasks_test.py +++ b/learning_resources/tasks_test.py @@ -238,10 +238,10 @@ def test_get_content_tasks( 3, etl_source=etl_source, platform=platform ) if with_learning_resource_ids: - learning_resource_ids = [ + learning_resource_ids = sorted([ courses[0].learning_resource_id, courses[1].learning_resource_id, - ] + ], reverse=True) else: learning_resource_ids = None s3_prefix = "course-prefix" From 49369613a4bc0d798bc5927c895a62d1a6b91989 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 20:56:47 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- learning_resources/tasks.py | 10 +++++++--- learning_resources/tasks_test.py | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/learning_resources/tasks.py b/learning_resources/tasks.py index fe6a064ef0..7e937b4be8 100644 --- a/learning_resources/tasks.py +++ b/learning_resources/tasks.py @@ -207,9 +207,13 @@ def get_content_tasks( # noqa: PLR0913 ) if learning_resource_ids: - learning_resources = LearningResource.objects.filter( - id__in=learning_resource_ids, etl_source=etl_source - ).order_by("-id").values_list("id", flat=True) + learning_resources = ( + LearningResource.objects.filter( + id__in=learning_resource_ids, etl_source=etl_source + ) + .order_by("-id") + .values_list("id", flat=True) + ) else: learning_resources = ( LearningResource.objects.filter(Q(published=True) | Q(test_mode=True)) diff --git a/learning_resources/tasks_test.py b/learning_resources/tasks_test.py index ee0d038765..143b5ecfd2 100644 --- a/learning_resources/tasks_test.py +++ b/learning_resources/tasks_test.py @@ -238,10 +238,13 @@ def test_get_content_tasks( 3, etl_source=etl_source, platform=platform ) if with_learning_resource_ids: - learning_resource_ids = sorted([ - courses[0].learning_resource_id, - courses[1].learning_resource_id, - ], reverse=True) + learning_resource_ids = sorted( + [ + courses[0].learning_resource_id, + courses[1].learning_resource_id, + ], + reverse=True, + ) else: learning_resource_ids = None s3_prefix = "course-prefix"