forked from kstateome/canvas-api
-
Notifications
You must be signed in to change notification settings - Fork 2
allow deletetion by lti context id #76
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
Merged
sebastianchristopher
merged 6 commits into
master
from
allow-deletetion-by-lti-context-id
Feb 5, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
81c88b5
allow deletetion by lti context id
sebastianchristopher db88c15
Update src/main/java/edu/ksu/canvas/interfaces/AssignmentWriter.java
sebastianchristopher 046f4e1
allow deletion by lti context id
sebastianchristopher b72f923
Initial plan
Copilot 93cdc56
Add test coverage for deleteAssignment methods
Copilot e10b720
Merge pull request #77 from oxctl/copilot/sub-pr-76
sebastianchristopher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
src/test/java/edu/ksu/canvas/tests/assignment/AssignmentWriterUTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package edu.ksu.canvas.tests.assignment; | ||
|
|
||
| import edu.ksu.canvas.CanvasTestBase; | ||
| import edu.ksu.canvas.impl.AssignmentImpl; | ||
| import edu.ksu.canvas.interfaces.AssignmentWriter; | ||
| import edu.ksu.canvas.model.assignment.Assignment; | ||
| import edu.ksu.canvas.net.FakeRestClient; | ||
| import junit.framework.AssertionFailedError; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Optional; | ||
|
|
||
| public class AssignmentWriterUTest extends CanvasTestBase { | ||
|
|
||
| @Autowired | ||
| private FakeRestClient fakeRestClient; | ||
| private AssignmentWriter assignmentWriter; | ||
|
|
||
| @Before | ||
| public void setupData() { | ||
| assignmentWriter = new AssignmentImpl(baseUrl, apiVersion, SOME_OAUTH_TOKEN, fakeRestClient, SOME_CONNECT_TIMEOUT, SOME_READ_TIMEOUT, DEFAULT_PAGINATION_PAGE_SIZE, false); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDeleteAssignmentWithIntegerId() throws IOException { | ||
| String someCourseId = "1234"; | ||
| Integer someAssignmentId = 123; | ||
| String url = baseUrl + "/api/v1/courses/" + someCourseId + "/assignments/" + someAssignmentId; | ||
| fakeRestClient.addSuccessResponse(url, "SampleJson/assignment/DeletedAssignment.json"); | ||
| Optional<Assignment> deletedAssignmentOpt = assignmentWriter.deleteAssignment(someCourseId, someAssignmentId); | ||
| Assignment deletedAssignment = deletedAssignmentOpt.orElseThrow(AssertionFailedError::new); | ||
| Assert.assertEquals("Assignment1", deletedAssignment.getName()); | ||
| Assert.assertEquals(Integer.valueOf(1), deletedAssignment.getId()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDeleteAssignmentWithStringId() throws IOException { | ||
| String someCourseId = "1234"; | ||
| String someAssignmentId = "lti_context_id:ab84f579-4442-4d4a-acd8-85c5ec6fd2b6"; | ||
| String url = baseUrl + "/api/v1/courses/" + someCourseId + "/assignments/" + someAssignmentId; | ||
| fakeRestClient.addSuccessResponse(url, "SampleJson/assignment/DeletedAssignment.json"); | ||
| Optional<Assignment> deletedAssignmentOpt = assignmentWriter.deleteAssignment(someCourseId, someAssignmentId); | ||
| Assignment deletedAssignment = deletedAssignmentOpt.orElseThrow(AssertionFailedError::new); | ||
| Assert.assertEquals("Assignment1", deletedAssignment.getName()); | ||
| Assert.assertEquals(Integer.valueOf(1), deletedAssignment.getId()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDeleteAssignmentWithNumericStringId() throws IOException { | ||
| String someCourseId = "1234"; | ||
| String someAssignmentId = "456"; | ||
| String url = baseUrl + "/api/v1/courses/" + someCourseId + "/assignments/" + someAssignmentId; | ||
| fakeRestClient.addSuccessResponse(url, "SampleJson/assignment/DeletedAssignment.json"); | ||
| Optional<Assignment> deletedAssignmentOpt = assignmentWriter.deleteAssignment(someCourseId, someAssignmentId); | ||
| Assignment deletedAssignment = deletedAssignmentOpt.orElseThrow(AssertionFailedError::new); | ||
| Assert.assertEquals("Assignment1", deletedAssignment.getName()); | ||
| Assert.assertEquals(Integer.valueOf(1), deletedAssignment.getId()); | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/test/resources/SampleJson/assignment/DeletedAssignment.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "id": 1, | ||
| "description": "", | ||
| "due_at": null, | ||
| "unlock_at": null, | ||
| "lock_at": null, | ||
| "points_possible": 30, | ||
| "grading_type": "points", | ||
| "assignment_group_id": 1967, | ||
| "grading_standard_id": null, | ||
| "created_at": "2016-10-28T19:37:50Z", | ||
| "updated_at": "2016-10-28T19:37:50Z", | ||
| "peer_reviews": false, | ||
| "automatic_peer_reviews": false, | ||
| "position": 1, | ||
| "grade_group_students_individually": false, | ||
| "anonymous_peer_reviews": false, | ||
| "group_category_id": null, | ||
| "post_to_sis": false, | ||
| "moderated_grading": false, | ||
| "omit_from_final_grade": false, | ||
| "course_id": 1146, | ||
| "name": "Assignment1", | ||
| "submission_types": [ | ||
| "none" | ||
| ], | ||
| "has_submitted_submissions": false, | ||
| "muted": false, | ||
| "html_url": "https://canvas.example.edu/courses/1146/assignments/316000", | ||
| "has_overrides": false, | ||
| "needs_grading_count": 0, | ||
| "integration_id": null, | ||
| "integration_data": {}, | ||
| "published": false, | ||
| "unpublishable": true, | ||
| "only_visible_to_overrides": false, | ||
| "locked_for_user": false, | ||
| "submissions_download_url": "https://canvas.example.edu/courses/1146/assignments/316000/submissions?zip=1", | ||
| "workflow_state": "deleted" | ||
| } |
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.
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.
The new String-based deleteAssignment overload lacks test coverage. While the existing Integer-based deleteAssignment method also doesn't have explicit tests, this pattern follows the editAssignment methods which similarly lack explicit tests. However, given that this codebase has comprehensive test coverage for other writer operations (as seen in CalendarWriterUTest, CourseManagerUTest, etc.), consider adding test coverage for both delete methods to maintain consistency with other tested writer methods like createAssignment.
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.
@copilot open a new pull request to apply changes based on this feedback