-
Notifications
You must be signed in to change notification settings - Fork 86
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
Initial attempt at grouped allowance endpoint #892
Conversation
Added grouped allowance function within views and the endpoint within urls.py. Added test cases to test_views.py.
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.
See my inline feedback. Good work. Most of my feedback are to help you make this a bit cleaner. But the logic is sound.
edx_proctoring/views.py
Outdated
for allowance in all_allowances: | ||
serialied_allowance = ProctoredExamStudentAllowanceSerializer(allowance).data | ||
user_id = serialied_allowance['user']['id'] | ||
if user_id in grouped_allowances: |
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.
Use setdefault function here would help simplify these 4 lines
|
||
**Expected Response** | ||
HTTP GET: | ||
The response will contain a dictionary with the allowances of a course grouped by student. |
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.
#NIT can you provide an example response here? It makes the comments on this function much easier to read.
edx_proctoring/tests/test_views.py
Outdated
grouped_allowances = response_data['grouped_allowances'] | ||
self.assertEqual(len(grouped_allowances), 3) | ||
# Check that all users allowances are inputted correctly | ||
first_user = str(user_list[0].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.
Could you write a function that would compare the returned dictionary with the expected dictionary? We have assertDictEqual function to help make sure all the elements are correct.
self.assertEqual(len(grouped_allowances[first_user]), 2) | ||
self.assertNotEqual(grouped_allowances[first_user][0], grouped_allowances[first_user][1]) | ||
|
||
def test_get_grouped_allowances_non_staff(self): |
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 missing a test case where the user is a course staff, not a global staff. For example, see https://github.com/edx/edx-proctoring/blob/f1ebee0814ac45f7b11d030df4991f4ccea082bd/edx_proctoring/tests/test_views.py#L473
Added comments/refactored code to be more concise/readable. Adjust test case to be more thorough.
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.
👍
Added grouped allowance function within views and the endpoint within urls.py. Added test cases to test_views.py.
Description:
Describe in a couple of sentences how this pull request modifies the repository.
JIRA:
MST-845
Pre-Merge Checklist:
edx_proctoring/__init__.py
andpackage.json
if these changes are to be released.CHANGELOG.rst
Post-Merge: