Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas12091101 committed Jan 7, 2025
1 parent e06d8f1 commit ec70ca6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lms/djangoapps/courseware/tests/test_date_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,37 @@ def test_course_start_date(self):
block = CourseStartDate(course, user)
assert block.date == course.start

@ddt.data(
# Instructor-paced course: Use course start date
(False, datetime(2025, 1, 10, tzinfo=utc), datetime(2025, 1, 12, tzinfo=utc),
datetime(2025, 1, 10, tzinfo=utc), 'Course starts'),
# Self-paced course: Enrollment created later than course start
(True, datetime(2025, 1, 10, tzinfo=utc), datetime(2025, 1, 12), datetime(2025, 1, 12, tzinfo=utc),
'Enrollment Date'),
# Self-paced course: Enrollment created earlier than course start
(True, datetime(2025, 1, 10, tzinfo=utc), datetime(2025, 1, 8), datetime(2025, 1, 10, tzinfo=utc),
'Course starts'),
# Self-paced course: No enrollment
(True, datetime(2025, 1, 10, tzinfo=utc), None, datetime(2025, 1, 10, tzinfo=utc), 'Course starts'),
)
@ddt.unpack
def test_course_start_date_label(self, self_paced, course_start, enrollment_created, expected_date, expected_title):
"""
Test the CourseStartDate class has correct label for course start date
"""
course = CourseFactory(self_paced=self_paced, start=course_start)
user = create_user()
if enrollment_created:
enrollment = CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.VERIFIED)
enrollment.created = enrollment_created
enrollment.save()
date_summary = CourseStartDate(user=user, course=course)
self.assertEqual(date_summary.date, expected_date)
self.assertEqual(str(date_summary.title), expected_title)

## Tests Course End Date Block
def test_course_end_date_for_certificate_eligible_mode(self):
course = create_course_run(days_till_start=-1)
Expand Down

0 comments on commit ec70ca6

Please sign in to comment.