Skip to content

Commit

Permalink
styling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmnhou committed Dec 3, 2024
1 parent 2de1083 commit 42876bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
19 changes: 10 additions & 9 deletions canvasapi/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,6 @@ def upload(self, file: FileOrPathLike, **kwargs):
return Uploader(
self._requester, "courses/{}/files".format(self.id), file, **kwargs
).start()


def get_lti_resource_links(self, **kwargs):
"""
Expand All @@ -2773,15 +2772,15 @@ def get_lti_resource_links(self, **kwargs):
:rtype: :class:`canvasapi.paginated_list.PaginatedList`
"""
from canvasapi.lti_resource_link import LTIResourceLink

return PaginatedList(
LTIResourceLink,
self._requester,
"GET",
f"courses/{self.id}/lti_resource_links",
kwargs=combine_kwargs(**kwargs)
kwargs=combine_kwargs(**kwargs),
)

def get_lti_resource_link(self, lti_resource_link, **kwargs):
"""
Return details about the specified resource link.
Expand All @@ -2796,15 +2795,17 @@ def get_lti_resource_link(self, lti_resource_link, **kwargs):
"""
from canvasapi.lti_resource_link import LTIResourceLink

lti_resource_link_id = obj_or_id(lti_resource_link, "lti_resource_link", (LTIResourceLink,))
lti_resource_link_id = obj_or_id(
lti_resource_link, "lti_resource_link", (LTIResourceLink,)
)

response = self._requester.request(
"GET",
f"courses/{self.id}/lti_resource_links/{lti_resource_link_id}",
_kwargs=combine_kwargs(**kwargs)
_kwargs=combine_kwargs(**kwargs),
)
return LTIResourceLink(self._requester, response.json())

def create_lti_resource_link(self, url, title=None, custom=None, **kwargs):
"""
Create a new LTI resource link.
Expand All @@ -2827,7 +2828,7 @@ def create_lti_resource_link(self, url, title=None, custom=None, **kwargs):

if not url:
raise RequiredFieldMissing("The 'url' paramter is required.")

kwargs["url"] = url
if title:
kwargs["title"] = title
Expand All @@ -2837,7 +2838,7 @@ def create_lti_resource_link(self, url, title=None, custom=None, **kwargs):
response = self._requester.request(
"POST",
f"courses/{self.id}/lti_resource_links",
_kwargs=combine_kwargs(**kwargs)
_kwargs=combine_kwargs(**kwargs),
)
return LTIResourceLink(self._requester, response.json())

Expand Down
9 changes: 3 additions & 6 deletions canvasapi/lti_resource_link.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from canvasapi.canvas_object import CanvasObject
from canvasapi.paginated_list import PaginatedList
from canvasapi.util import combine_kwargs, obj_or_id
from canvasapi.course import Course
from canvasapi.exceptions import RequiredFieldMissing


class LTIResourceLink(CanvasObject):
def __init__(self, requester, attributes):
super(LTIResourceLink, self).__init__(requester, attributes)

def __str__(self):
return "{} ({})".format(self.url, self.title)
return "{} ({})".format(self.url, self.title)
10 changes: 7 additions & 3 deletions tests/test_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,12 +1890,13 @@ def test_resolve_path_null(self, m):
self.assertEqual(len(root_folder_list), 1)
self.assertIsInstance(root_folder_list[0], Folder)
self.assertEqual("course_files", root_folder_list[0].name)

# create_lti_resource_link()
def test_create_lti_resource_link(self, m):
register_uris({"lti_resource_link": ["create_lti_resource_link"]}, m)
evnt = self.course.create_lti_resource_link(
url="https://example.com/lti/launch/content_item/123", title="Test LTI Resource Link",
url="https://example.com/lti/launch/content_item/123",
title="Test LTI Resource Link",
)
self.assertIsInstance(evnt, LTIResourceLink)
self.assertEqual(evnt.title, "Test LTI Resource Link")
Expand All @@ -1917,10 +1918,13 @@ def test_get_lti_resource_link(self, m):
lti_resource_link_by_id = self.course.get_lti_resource_link(45)
self.assertIsInstance(lti_resource_link_by_id, LTIResourceLink)
self.assertEqual(lti_resource_link_by_id.title, "Test LTI Resource Link")
lti_resource_link_by_obj = self.course.get_lti_resource_link(lti_resource_link_by_id)
lti_resource_link_by_obj = self.course.get_lti_resource_link(
lti_resource_link_by_id
)
self.assertIsInstance(lti_resource_link_by_obj, LTIResourceLink)
self.assertEqual(lti_resource_link_by_obj.title, "Test LTI Resource Link")


@requests_mock.Mocker()
class TestCourseNickname(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 42876bd

Please sign in to comment.