-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: update pearson engine api client #245
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally functionality is working I just left some minor comments
user_data = { | ||
"username": user.username, | ||
"first_name": user.first_name, | ||
"last_name": user.last_name, | ||
"email": user.email, | ||
"country": user.profile.country.code, | ||
"city": user.profile.city, | ||
"phone": user.profile.phone_number, | ||
"address": user.profile.mailing_address, | ||
"arabic_full_name": user.extrainfo.arabic_name, | ||
"arabic_first_name": user.extrainfo.arabic_first_name, | ||
"arabic_last_name": user.extrainfo.arabic_last_name, | ||
} | ||
|
||
if user.extrainfo.national_id: | ||
user_data["national_id"] = user.extrainfo.national_id | ||
|
||
return user_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are not being tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it covered now,
eox_nelp/pearson_vue/utils.py
Outdated
return { | ||
"name": settings.PLATFORM_NAME, | ||
"tenant": getattr(settings, "EDNX_TENANT_DOMAIN", None) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are not being tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it covered now,
eox_nelp/pearson_vue/utils.py
Outdated
return { | ||
"external_key": exam_id, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are not being tested
eox_nelp/pearson_vue/utils.py
Outdated
} | ||
|
||
|
||
def generate_action_parameters(user, exam_id=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need exam_id=None
?
eox_nelp/pearson_vue/utils.py
Outdated
|
||
|
||
def get_exam_data(exam_id): | ||
"""Retrieve exam data for the request payload. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works for the request payload, I cannot use this method for other thing ?
"""Test real-time import action using the Pearson Engine API. | ||
|
||
Expected behavior: | ||
- update_user_engines is called with correct parameters. | ||
- The real_time_import method is called with the correct parameters. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
|
||
@patch("eox_nelp.pearson_vue.tasks.update_user_engines") | ||
@patch("eox_nelp.pearson_vue.tasks.generate_action_parameters") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are doing nothing with this mock, why do you need that in every single test when you can make a general mock ?
2f93d9e
to
272e294
Compare
I fixed the tests as you suggested and improved the coverage in the utils file. Additionally, I made some minor fixes.
I also made an squash for related commits in this branch. |
In the future please don't squash commits it's not clear what changes you made |
@@ -186,6 +195,7 @@ def test_real_time_import_invalid_action(self, update_user_engines_mock): | |||
with self.assertRaises(KeyError): | |||
real_time_import_task_v2(self.user.id, action_name="invalid_action") | |||
update_user_engines_mock.assert_not_called() | |||
self.generate_action_parameters_mock.assert_not_called() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this verification to the expected behavior doc string
@@ -201,6 +211,7 @@ def test_real_time_import_user_not_found(self, mock_api_client, update_user_engi | |||
real_time_import_task_v2(12345678, action_name="rti") | |||
mock_api_client.assert_not_called() | |||
update_user_engines_mock.assert_not_called() | |||
self.generate_action_parameters_mock.assert_not_called() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
self.user = MagicMock() | ||
self.user.username = "testuser" | ||
self.user.first_name = "Test" | ||
self.user.last_name = "User" | ||
self.user.email = "test@example.com" | ||
self.user.profile.country.code = "US" | ||
self.user.profile.city = "Test City" | ||
self.user.profile.phone_number = "123-456-7890" | ||
self.user.profile.mailing_address = "123 Test St" | ||
self.user.extrainfo.arabic_name = "اسم المستخدم" | ||
self.user.extrainfo.arabic_first_name = "الاسم الاول" | ||
self.user.extrainfo.arabic_last_name = "اسم العائلة" | ||
self.user.extrainfo.national_id = "123456789" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.user = MagicMock() | |
self.user.username = "testuser" | |
self.user.first_name = "Test" | |
self.user.last_name = "User" | |
self.user.email = "test@example.com" | |
self.user.profile.country.code = "US" | |
self.user.profile.city = "Test City" | |
self.user.profile.phone_number = "123-456-7890" | |
self.user.profile.mailing_address = "123 Test St" | |
self.user.extrainfo.arabic_name = "اسم المستخدم" | |
self.user.extrainfo.arabic_first_name = "الاسم الاول" | |
self.user.extrainfo.arabic_last_name = "اسم العائلة" | |
self.user.extrainfo.national_id = "123456789" | |
self.user = MagicMock( | |
username="testuser", | |
first_name="Test", | |
last_name="User", | |
email="test@example.com", | |
profile=MagicMock( | |
country=MagicMock(code="US"), | |
city="Test City", | |
phone_number="123-456-7890", | |
mailing_address="123 Test St", | |
), | |
extrainfo=MagicMock( | |
arabic_name="اسم المستخدم", | |
arabic_first_name="الاسم الاول", | |
arabic_last_name="اسم العائلة", | |
national_id="123456789", | |
), | |
) |
- The result is a dict with all user data. | ||
""" | ||
expected_result = { | ||
"username": "testuser", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"username": "testuser", | |
"username": self.user.username, | |
... |
Expected behavior: | ||
- The result is a dict with platform name and tenant domain. | ||
""" | ||
self.mock_settings.PLATFORM_NAME = "Test Platform" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use override_settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a nice DJango feature for testing.
I just updated the case.
Expected behavior: | ||
- The result is a dict with platform name and tenant is None. | ||
""" | ||
self.mock_settings.PLATFORM_NAME = "Test Platform" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
272e294
to
1827e9e
Compare
b182944
to
b796212
Compare
- update pearson engine client action parameters
1827e9e
to
2bca602
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add missing trailing commas
eox_nelp/pearson_vue/utils.py
Outdated
action_parameters = { | ||
"user_data": get_user_data(user), | ||
"platform_data": get_platform_data(), | ||
"exam_data": {"external_key": exam_id} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"exam_data": {"external_key": exam_id} | |
"exam_data": {"external_key": exam_id}, |
eox_nelp/pearson_vue/utils.py
Outdated
""" | ||
return { | ||
"name": settings.PLATFORM_NAME, | ||
"tenant": getattr(settings, "EDNX_TENANT_DOMAIN", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"tenant": getattr(settings, "EDNX_TENANT_DOMAIN", None) | |
"tenant": getattr(settings, "EDNX_TENANT_DOMAIN", None), |
Description
This PR removes the
pearson_engine
module from the deprecatedapi_clients
package and introduces modifications to thereal_time_import_task_v2
task.Changes
pearson_engine
imports in thepearson_vue.tasks
file.pearson_engine
, additional parameters for theCDD
,EAD
, andRTI
requests were needed. A new method was added to generate these parameters.real_time_import_task_v2
to reflect the changes.pearson_vue.utils
to cover the new methods.Tests
Local

CDD
,EAD
andRTI
action - requests.