Fix failing tests#1535
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses failing tests by reducing external/service dependencies in exercise submission tests, aligning API exception types with DRF expectations, and expanding user list filtering to support a dedicated field/values filter in addition to search.
Changes:
- Updated the users API list endpoint to allow
FieldValuesFilter-based filtering (in addition tosearch) while still preventing unfiltered user listing. - Adjusted
test_uploading_and_viewing_fileto avoid exercising remote feedback-page loading when the test intent is file upload/view behavior. - Switched exercise API mixins to raise DRF
NotFoundinstead of DjangoHttp404for consistent API error handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| userprofile/api/views.py | Adds FieldValuesFilter support and relaxes list restrictions when a field-based filter is provided. |
| exercise/tests.py | Patches out feedback-page loading during upload/view test to isolate test intent and avoid external calls. |
| exercise/api/mixins.py | Uses DRF NotFound exceptions for missing exercise/submission objects in API mixins. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Nice, I made some changes.
Reverted the Http404 -> NotFound() change, since the other mixins like authorization/api/mixins.py and course/api/mixins.py also use Http404() and DRF converts it to a NotFound() automatically anyway.
I also made some fixes so that tracebacks from tests that are expected to raise exceptions do not pollute the test output.
All tests should now pass.
Exclude already-loaded modules from incremental ContentDBData fetches, preserve CourseModule ordering after merging batches, and add regression coverage for loading a module before its containing instance.
Description
What?
Several tests were failing in the a-plus test suite. Fix these issues
Why?
To improve testing functionality to catch possible future issues
How?
Edited test_uploading_and_viewing_file in exercise/tests.py to make the test assert the file uploading and viewing independently of feedback rendering.
Edited exercise/mixins.py to raise DRF NotFound instead of Django error message so that the tests can catch the correct error message.
FInally, edited get_queryset in api/views.py so that the sets can be searched with either search- or view-based filtering.
Testing
Remember to add or update unit tests for new features and changes.
What type of test did you run?
In addition to verifying several times that the test suite now passes, I also briefly checked that the local Docker image also works.
Did you test the changes in
Think of what is affected by these changes and could become broken
Translation
Programming style
Have you updated the README or other relevant documentation?
Is it Done?
Clean up your git commit history before submitting the pull request!