Skip to content

Commit

Permalink
feat: elegibility_appt_data runtime calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
johanseto committed Jul 12, 2024
1 parent a640038 commit 1936c70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions eox_nelp/pearson_vue/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ def get_exam_data(user_id, course_id, **kwargs): # pylint: disable=unused-argum
User.objects.get(id=user_id),
course_id,
)
# configure eligibility appt date with settings course delta starting from now. Default one year.
elegibility_appt_delta_days = exam_metadata.get("elegibility_appt_delta_days", 365)
exam_metadata["eligibility_appt_date_first"] = timezone.now().strftime("%Y/%m/%d %H:%M:%S")
exam_metadata["eligibility_appt_date_last"] = (
timezone.now() + timezone.timedelta(days=elegibility_appt_delta_days)
).strftime("%Y/%m/%d %H:%M:%S")

required_fields = {
"eligibility_appt_date_first",
Expand Down
15 changes: 8 additions & 7 deletions eox_nelp/pearson_vue/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,29 +597,31 @@ def tearDown(self):
"""Restore mocks' state"""
CourseEnrollment.reset_mock()

@patch.object(timezone, "now")
@override_settings()
def test_get_exam_data_success(self):
def test_get_exam_data_success(self, mock_now):
"""
Test that the get_exam_data function return the set values.
Expected behavior:
- The result is the expected value.
"""
mock_now.return_value = timezone.datetime(2024, 5, 20, 12, 0, 0)
exam_data = {
"eligibility_appt_date_first": "2024/05/05 12:00:00",
"eligibility_appt_date_last": "2025/05/05 12:00:00",
"exam_authorization_count": 3,
"exam_series_code": "ABD",
"eligibility_appt_date_first": mock_now().strftime("%Y/%m/%d %H:%M:%S"),
"eligibility_appt_date_last": (mock_now() + timezone.timedelta(days=365)).strftime("%Y/%m/%d %H:%M:%S"),
}
course_id = self.course_id
course_settings = {
course_id: exam_data
course_id: exam_data.copy()
}
setattr(settings, "PEARSON_RTI_COURSES_DATA", course_settings)

result = get_exam_data(self.user.id, course_id)

self.assertEqual(result["exam_metadata"], exam_data)
for key, value in exam_data.items():
self.assertEqual(result["exam_metadata"][key], value)

@override_settings()
def test_get_exam_data_failure(self):
Expand All @@ -634,7 +636,6 @@ def test_get_exam_data_failure(self):
course_settings = {
course_id: {
"invalid_key": "test",
"eligibility_appt_date_last": "2024/05/05 12:00:00",
"exam_authorization_count": 4,
}
}
Expand Down

0 comments on commit 1936c70

Please sign in to comment.