Skip to content

Commit

Permalink
feat: add timezones constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mumarkhan999 committed Nov 5, 2024
1 parent 96a68e3 commit 1042fd7
Show file tree
Hide file tree
Showing 3 changed files with 422 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lms/djangoapps/mobile_api/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
ALLOW_ACCESS_TO_UNRELEASED_COURSE = True
ALLOW_ACCESS_TO_MILESTONE_COURSE = True
ALLOW_ACCESS_TO_NON_VISIBLE_COURSE = True
NEXT_WEEK = datetime.datetime.now(ZoneInfo("UTC")) + datetime.timedelta(days=7)
LAST_WEEK = datetime.datetime.now(ZoneInfo("UTC")) - datetime.timedelta(days=7)
NEXT_WEEK = datetime.datetime.now(ZoneInfo('UTC')) + datetime.timedelta(days=7)
LAST_WEEK = datetime.datetime.now(ZoneInfo('UTC')) - datetime.timedelta(days=7)
THREE_YEARS_AGO = now() - datetime.timedelta(days=(365 * 3))
ADVERTISED_START = "Spring 2016"
ENABLED_SIGNALS = ['course_published']
Expand Down Expand Up @@ -1438,7 +1438,7 @@ def test_user_have_active_and_inactive_enrollments_and_no_completions(self) -> N
old_course = CourseFactory.create(org="edx", mobile_available=True)
self.enroll(old_course.id)
old_enrollment = CourseEnrollment.objects.filter(user=self.user, course=old_course.course_id).first()
old_enrollment.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=31)
old_enrollment.created = datetime.datetime.now(ZoneInfo('UTC')) - datetime.timedelta(days=31)
old_enrollment.save()

response = self.api_response(api_version=API_V1)
Expand Down Expand Up @@ -1466,7 +1466,7 @@ def test_different_enrollment_dates(self, enrolled_days_ago: int, recently_activ
course = CourseFactory.create(org="edx", mobile_available=True, run='1001')
self.enroll(course.id)
enrollment = CourseEnrollment.objects.filter(user=self.user, course=course.course_id).first()
enrollment.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=enrolled_days_ago)
enrollment.created = datetime.datetime.now(ZoneInfo('UTC')) - datetime.timedelta(days=enrolled_days_ago)
enrollment.save()

response = self.api_response(api_version=API_V1)
Expand Down Expand Up @@ -1500,7 +1500,7 @@ def test_different_completion_dates(self, completed_days_ago: int, recently_acti
self.enroll(course.id)
enrollment = CourseEnrollment.objects.filter(user=self.user, course=course.course_id).first()
# make enrollment older 30 days ago
enrollment.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=50)
enrollment.created = datetime.datetime.now(ZoneInfo('UTC')) - datetime.timedelta(days=50)
enrollment.save()
completion = BlockCompletion.objects.create(
user=self.user,
Expand All @@ -1509,7 +1509,7 @@ def test_different_completion_dates(self, completed_days_ago: int, recently_acti
block_key=section.location,
completion=0.5,
)
completion.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=completed_days_ago)
completion.created = datetime.datetime.now(ZoneInfo('UTC')) - datetime.timedelta(days=completed_days_ago)
completion.save()

response = self.api_response(api_version=API_V1)
Expand Down
Loading

0 comments on commit 1042fd7

Please sign in to comment.