Skip to content

Commit

Permalink
Repair test based on dates (test_create_featured_items) (#2229)
Browse files Browse the repository at this point in the history
* Repair test based on dates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
collinpreston and pre-commit-ci[bot] authored May 30, 2024
1 parent b006819 commit c969aab
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions cms/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,38 +308,26 @@ def test_create_featured_items():
# Course that starts in the future but is open for enrollment
enrollable_future_course = CourseFactory.create(page=None, live=True)
CoursePageFactory.create(course=enrollable_future_course, live=True)
enrollable_future_courserun = CourseRunFactory.create(
enrollable_future_courserun = CourseRunFactory.create( # noqa: F841
course=enrollable_future_course,
live=True,
in_future=True,
start_date=future_date,
enrollment_start=further_past_date,
enrollment_end=further_future_date,
end_date=furthest_future_date,
)
enrollable_future_courserun.enrollment_start = further_past_date
enrollable_future_courserun.start_date = future_date
enrollable_future_courserun.enrollment_end = further_future_date
enrollable_future_courserun.end_date = furthest_future_date
enrollable_future_courserun.save()

# Course that is open for enrollment, but starts after the one above
enrollable_other_future_course = CourseFactory.create(page=None, live=True)
CoursePageFactory.create(course=enrollable_other_future_course, live=True)
enrollable_other_future_courserun = CourseRunFactory.create(
enrollable_other_future_courserun = CourseRunFactory.create( # noqa: F841
course=enrollable_other_future_course,
live=True,
in_future=True,
enrollment_start=further_past_date,
start_date=future_date + timedelta(days=2),
enrollment_end=further_future_date + timedelta(days=2),
end_date=furthest_future_date + timedelta(days=2),
)
enrollable_other_future_courserun.enrollment_start = (
enrollable_future_courserun.enrollment_start
)
enrollable_other_future_courserun.start_date = (
enrollable_future_courserun.start_date + timedelta(days=2)
)
enrollable_other_future_courserun.enrollment_end = (
enrollable_future_courserun.enrollment_end + timedelta(days=2)
)
enrollable_other_future_courserun.end_date = (
enrollable_future_courserun.end_date + timedelta(days=2)
)
enrollable_other_future_courserun.save()

# A self-paced course that is open for enrollment
enrollable_self_paced_course = CourseFactory.create(page=None, live=True)
Expand All @@ -348,6 +336,7 @@ def test_create_featured_items():
course=enrollable_self_paced_course,
live=True,
in_progress=True,
enrollment_end=further_future_date + timedelta(days=2),
)
self_paced_run.is_self_paced = True
self_paced_run.save()
Expand All @@ -358,11 +347,8 @@ def test_create_featured_items():
course=in_progress_course,
live=True,
in_progress=True,
enrollment_end=further_future_date + timedelta(days=2),
)
in_progress_course.enrollment_start = further_past_date
in_progress_course.start_date = past_date
in_progress_course.enrollment_end = future_date
in_progress_course.end_date = further_future_date

unenrollable_course = CourseFactory.create(page=None, live=False)
CoursePageFactory.create(course=unenrollable_course, live=False)
Expand Down

0 comments on commit c969aab

Please sign in to comment.