-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #673 from jsmnhou/issue/662-api-lti-resource-links
Issue/662 Add API coverage for LTI resource links
- Loading branch information
Showing
9 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,6 @@ | ||
from canvasapi.canvas_object import CanvasObject | ||
|
||
|
||
class LTIResourceLink(CanvasObject): | ||
def __str__(self): | ||
return "{} ({})".format(self.url, self.title) |
This file contains 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 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,6 @@ | ||
=============== | ||
LTIResourceLink | ||
=============== | ||
|
||
.. autoclass:: canvasapi.lti_resource_link.LTIResourceLink | ||
:members: |
This file contains 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,49 @@ | ||
{ | ||
"create_lti_resource_link": { | ||
"method": "POST", | ||
"endpoint": "courses/1/lti_resource_links", | ||
"data": { | ||
"id": 45, | ||
"context_id": 1, | ||
"context_type": "Course", | ||
"context_external_tool_id": 1, | ||
"resource_type": "assignment", | ||
"canvas_launch_url": "https://example.instructure.com/courses/1/external_tools/retrieve?resource_link_lookup_uuid=ae43ba23-d238-49bc-ab55-ba7f79f77896", | ||
"resource_link_uuid": "ae43ba23-d238-49bc-ab55-ba7f79f77896", | ||
"lookup_uuid": "c522554a-d4be-49ef-b163-9c87fdc6ad6f", | ||
"title": "Test LTI Resource Link", | ||
"url": "https://example.com/lti/launch/content_item/123" | ||
}, | ||
"status_code": 200 | ||
}, | ||
|
||
"get_lti_resource_link": { | ||
"method": "GET", | ||
"endpoint": "courses/1/lti_resource_links/45", | ||
"data": { | ||
"id": 45, | ||
"title": "Test LTI Resource Link", | ||
"url": "https://example.com/lti/launch/content_item/123" | ||
}, | ||
"status_code": 200 | ||
}, | ||
"list_lti_resource_links": { | ||
"method": "GET", | ||
"endpoint": "courses/1/lti_resource_links", | ||
"data": [ | ||
{ | ||
"id": 45, | ||
"title": "Test LTI Resource Link" | ||
}, | ||
{ | ||
"id": 56, | ||
"title": "Test LTI Resource Link 2" | ||
}, | ||
{ | ||
"id": 67, | ||
"title": "Test LTI Resource Link 3" | ||
} | ||
], | ||
"status_code": 200 | ||
} | ||
} |
This file contains 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 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,30 @@ | ||
import unittest | ||
|
||
import requests_mock | ||
|
||
from canvasapi import Canvas | ||
from tests import settings | ||
from tests.util import register_uris | ||
|
||
|
||
@requests_mock.Mocker() | ||
class TestLTIResourceLink(unittest.TestCase): | ||
def setUp(self): | ||
self.canvas = Canvas(settings.BASE_URL, settings.API_KEY) | ||
|
||
with requests_mock.Mocker() as m: | ||
register_uris( | ||
{ | ||
"course": ["get_by_id"], | ||
"lti_resource_link": ["get_lti_resource_link"], | ||
}, | ||
m, | ||
) | ||
|
||
self.course = self.canvas.get_course(1) | ||
self.resource_link = self.course.get_lti_resource_link(45) | ||
|
||
# __str__() | ||
def test__str__(self, m): | ||
string = str(self.resource_link) | ||
self.assertIsInstance(string, str) |