Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_external_tools(self, m):
requires = {"course": ["get_external_tools", "get_external_tools_p2"]}
register_uris(requires, m)
tools = self.course.get_external_tools()
tool_list = [tool for tool in tools]
self.assertIsInstance(tool_list[0], ExternalTool)
self.assertEqual(len(tool_list), 4)
def test_get_external_tool(self, m):
required = {"external_tool": ["get_by_id_account"]}
register_uris(required, m)
tool_by_id = self.account.get_external_tool(1)
self.assertIsInstance(tool_by_id, ExternalTool)
self.assertTrue(hasattr(tool_by_id, "name"))
tool_by_obj = self.account.get_external_tool(tool_by_id)
self.assertIsInstance(tool_by_obj, ExternalTool)
self.assertTrue(hasattr(tool_by_obj, "name"))
def test_get_external_tool(self, m):
register_uris({"external_tool": ["get_by_id_course"]}, m)
tool_by_id = self.course.get_external_tool(1)
self.assertIsInstance(tool_by_id, ExternalTool)
self.assertTrue(hasattr(tool_by_id, "name"))
tool_by_obj = self.course.get_external_tool(tool_by_id)
self.assertIsInstance(tool_by_obj, ExternalTool)
self.assertTrue(hasattr(tool_by_obj, "name"))
"""
from canvasapi.external_tool import ExternalTool
response = self._requester.request(
"POST",
"accounts/{}/external_tools".format(self.id),
name=name,
privacy_level=privacy_level,
consumer_key=consumer_key,
shared_secret=shared_secret,
_kwargs=combine_kwargs(**kwargs),
)
response_json = response.json()
response_json.update({"account_id": self.id})
return ExternalTool(self._requester, response_json)
"""
Remove the specified external tool.
:calls: `DELETE /api/v1/courses/:course_id/external_tools/:external_tool_id
`_
or `DELETE /api/v1/accounts/:account_id/external_tools/:external_tool_id
`_
:rtype: :class:`canvasapi.external_tool.ExternalTool`
"""
response = self._requester.request(
'DELETE',
'{}s/{}/external_tools/{}'.format(self.parent_type, self.parent_id, self.id)
)
return ExternalTool(self._requester, response.json())
"""
from canvasapi.external_tool import ExternalTool
response = self._requester.request(
"POST",
"courses/{}/external_tools".format(self.id),
name=name,
privacy_level=privacy_level,
consumer_key=consumer_key,
shared_secret=shared_secret,
_kwargs=combine_kwargs(**kwargs),
)
response_json = response.json()
response_json.update({"course_id": self.id})
return ExternalTool(self._requester, response_json)
def get_external_tools(self, **kwargs):
"""
:calls: `GET /api/v1/accounts/:account_id/external_tools \
`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.external_tool.ExternalTool`
"""
from canvasapi.external_tool import ExternalTool
return PaginatedList(
ExternalTool,
self._requester,
"GET",
"accounts/{}/external_tools".format(self.id),
{"account_id": self.id},
_kwargs=combine_kwargs(**kwargs),
)
:param tool: The object or ID of the tool to retrieve.
:type tool: :class:`canvasapi.external_tool.ExternalTool` or int
:rtype: :class:`canvasapi.external_tool.ExternalTool`
"""
from canvasapi.external_tool import ExternalTool
tool_id = obj_or_id(tool, "tool", (ExternalTool,))
response = self._requester.request(
"GET", "courses/{}/external_tools/{}".format(self.id, tool_id)
)
tool_json = response.json()
tool_json.update({"course_id": self.id})
return ExternalTool(self._requester, tool_json)
:param tool: The object or ID of the tool
:type tool: :class:`canvasapi.external_tool.ExternalTool` or int
:rtype: :class:`canvasapi.external_tool.ExternalTool`
"""
from canvasapi.external_tool import ExternalTool
tool_id = obj_or_id(tool, "tool", (ExternalTool,))
response = self._requester.request(
"GET", "accounts/{}/external_tools/{}".format(self.id, tool_id)
)
tool_json = response.json()
tool_json.update({"account_id": self.id})
return ExternalTool(self._requester, tool_json)