From 42876bd37e3772524f0a2b4a9177c1c668d25174 Mon Sep 17 00:00:00 2001 From: Jasmine Hou Date: Tue, 3 Dec 2024 17:16:54 -0500 Subject: [PATCH] styling fix --- canvasapi/course.py | 19 ++++++++++--------- canvasapi/lti_resource_link.py | 9 +++------ tests/test_course.py | 10 +++++++--- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/canvasapi/course.py b/canvasapi/course.py index df23845f..13467aa3 100644 --- a/canvasapi/course.py +++ b/canvasapi/course.py @@ -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): """ @@ -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. @@ -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. @@ -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 @@ -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()) diff --git a/canvasapi/lti_resource_link.py b/canvasapi/lti_resource_link.py index 9fc0e894..4d544cd2 100644 --- a/canvasapi/lti_resource_link.py +++ b/canvasapi/lti_resource_link.py @@ -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) \ No newline at end of file + return "{} ({})".format(self.url, self.title) diff --git a/tests/test_course.py b/tests/test_course.py index 061908ed..b993c221 100644 --- a/tests/test_course.py +++ b/tests/test_course.py @@ -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") @@ -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):