test: add tests for Canvas Integration plugin#790
Open
arslanashraf7 wants to merge 1 commit into
Open
Conversation
5a52f91 to
d50315e
Compare
asadali145
approved these changes
Jun 11, 2026
asadali145
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Just a couple of minor suggestions.
Comment on lines
+73
to
+81
| class MockSubsection: | ||
| """Minimal subsection object used for assignment payload generation tests.""" | ||
|
|
||
| def __init__(self, location, display_name, due=None): | ||
| """Initialize subsection location, name, and optional due date.""" | ||
| self.location = location | ||
| self.display_name = display_name | ||
| self.fields = {"due": due} if due else {} | ||
|
|
Contributor
There was a problem hiding this comment.
This is duplicate of subsection mock in test_api. Maybe create test utils for such stuff?
| return {"task_id": "test-task-id"} | ||
|
|
||
|
|
||
| class HashableUser: |
Contributor
There was a problem hiding this comment.
This and I think the above stub is also repeated.
| _call_view(view_func, request, course_id="") | ||
|
|
||
|
|
||
| def test_list_canvas_enrollments_raises_when_no_canvas_course_id(monkeypatch): |
Contributor
There was a problem hiding this comment.
I think this can be merged using parametrization with test_list_canvas_assignments_raises_when_no_canvas_course_id and test_list_canvas_grades_raises_when_no_canvas_course_id like above test.
| _call_view(views.list_canvas_enrollments, request, course_id=course_key) | ||
|
|
||
|
|
||
| def test_list_canvas_enrollments_success(monkeypatch): |
Contributor
There was a problem hiding this comment.
Same, this can be merged with parametrizartion with other success tests below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
https://github.com/mitodl/hq/issues/8200
This pull request introduces a comprehensive suite of new and improved tests for the
ol_openedx_canvas_integrationpackage. The changes focus on adding robust unit tests for the API, client, context API, handlers, and receivers modules. There are also some minor corrections and refactoring in test data structures and file organization. The overall goal is to ensure better coverage, reliability, and maintainability of the integration's core features.New and Improved Test Coverage:
apimodule, covering grade mapping, Canvas assignment creation/updating, and error handling for missing inputs.clientmodule, including Canvas session handling, pagination, enrollment lookups, caching, assignment CRUD operations, and payload formatting.context_apimodule, verifying resource loading and context section injection for Canvas integration.Test Data Structure and File Organization Improvements:
test_cms_tasks.pyto use the correct assignment dictionary structure (mapping to dicts withidkeys instead of plain ints) for consistency with production code. [1] [2]test_cms_tasks.pyandtest_settings.pyto the maintestsdirectory and updating path logic accordingly. [1] [2]These changes significantly improve the reliability of the integration by ensuring that core logic is well-tested and that test data structures match the expectations of the production code.
Description (What does it do?)
Screenshots (if appropriate):
How can this be tested?
Additional Context