Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: elegibility_appt_dates runtime calculations #198

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions eox_nelp/pearson_vue/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@ 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"] = (
Comment on lines +328 to +329
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these fields from the required_fields variable

timezone.now() + timezone.timedelta(days=elegibility_appt_delta_days)
).strftime("%Y/%m/%d %H:%M:%S")

required_fields = {
"eligibility_appt_date_first",
"eligibility_appt_date_last",
"exam_authorization_count",
"exam_series_code",
}
Expand Down
18 changes: 11 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,34 @@ 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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not testing your changes... indeed if you revert the pipeline changes this test passes

"""
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)
course_id = self.course_id
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",
}
course_id = self.course_id
course_settings = {
course_id: exam_data
}
setattr(settings, "PEARSON_RTI_COURSES_DATA", course_settings)
expected_data = {
**exam_data,
"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"),
}

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

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

@override_settings()
def test_get_exam_data_failure(self):
Expand All @@ -634,7 +639,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
Loading