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_combine_kwargs_multiple_dicts(self, m):
result = combine_kwargs(var1={"foo": "bar"}, var2={"fizz": "buzz"})
self.assertIsInstance(result, list)
self.assertEqual(len(result), 2)
self.assertIn(("var1[foo]", "bar"), result)
self.assertIn(("var2[fizz]", "buzz"), result)
def get_outcome_results(self, **kwargs):
"""
Get all outcome results for context - BETA
:calls: `GET /api/v1/courses/:course_id/outcome_results \
`_
:returns: List of potential related outcome result dicts.
:rtype: dict
"""
response = self._requester.request(
"GET",
"courses/{}/outcome_results".format(self.id),
_kwargs=combine_kwargs(**kwargs),
)
return response.json()
def delete(self, **kwargs):
"""
Remove this folder. You can only delete empty folders unless you set the
'force' flag.
:calls: `DELETE /api/v1/folders/:id \
`_
:rtype: :class:`canvasapi.folder.Folder`
"""
response = self._requester.request(
'DELETE',
'folders/{}'.format(self.id),
_kwargs=combine_kwargs(**kwargs)
)
return Folder(self._requester, response.json())
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of :class:`canvasapi.user.User`
"""
from canvasapi.appointment_group import AppointmentGroup
from canvasapi.user import User
appointment_group_id = obj_or_id(
appointment_group, "appointment_group", (AppointmentGroup,)
)
return PaginatedList(
User,
self.__requester,
"GET",
"appointment_groups/{}/users".format(appointment_group_id),
_kwargs=combine_kwargs(**kwargs),
)
"""
Lists all enabled features in an account.
:calls: `GET /api/v1/accounts/:account_id/features/enabled \
`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.feature.Feature`
"""
return PaginatedList(
Feature,
self._requester,
"GET",
"accounts/{}/features/enabled".format(self.id),
{"account_id": self.id},
_kwargs=combine_kwargs(**kwargs),
)
def delete(self, **kwargs):
"""
Delete a single poll, based on the poll id.
:calls: `DELETE /api/v1/polls/:poll_id/poll_choices/:id \
`_
:returns: True if the deletion was successful, false otherwise.
:rtype: bool
"""
response = self._requester.request(
'DELETE',
'polls/{}/poll_choices/{}'.format(self.poll_id, self.id),
_kwargs=combine_kwargs(**kwargs)
)
return response.status_code == 204
:calls: `GET /api/v1/accounts/:account_id/sis_imports/importing \
`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList`
of :class:`canvasapi.sis_import.SisImport`
"""
return PaginatedList(
SisImport,
self._requester,
"GET",
"accounts/{}/sis_imports/importing".format(self.id),
{"account_id": self.id},
_root="sis_imports",
_kwargs=combine_kwargs(**kwargs),
)
raise RequiredFieldMissing(
"`validation_token` not set on this QuizSubmissionQuestion, must be passed"
" as a function argument."
)
# Only the latest attempt for a quiz submission can be updated, and Canvas
# automatically returns the latest attempt with every quiz submission response,
# so we can just use that.
kwargs["attempt"] = self.attempt
response = self._requester.request(
"PUT",
"quiz_submissions/{}/questions/{}/unflag".format(
self.quiz_submission_id, self.id
),
_kwargs=combine_kwargs(**kwargs),
)
question = response.json()["quiz_submission_questions"][0]
question.update(
{
"validation_token": kwargs["validation_token"],
"quiz_submission_id": self.quiz_submission_id,
}
)
super(QuizSubmissionQuestion, self).set_attributes(question)
return True
kwargs.update(ids=entry_ids)
return PaginatedList(
DiscussionEntry,
self._requester,
'GET',
'{}s/{}/discussion_topics/{}/entry_list'.format(
self._parent_type,
self._parent_id,
self.id
),
{
'discussion_id': self.id,
'{}_id'.format(self._parent_type): self._parent_id
},
_kwargs=combine_kwargs(**kwargs),
)
:calls: `GET /api/v1/courses/:course_id/epub_exports/:id\
`_
:param epub: Object or ID of ePub Export
:type epub: int or :class:`canvasapi.course_epub_export.CourseEpubExport`
:rtype: :class:`canvasapi.course_epub_export.CourseEpubExport`
"""
epub_id = obj_or_id(epub, "epub", (CourseEpubExport,))
response = self._requester.request(
"GET",
"courses/{}/epub_exports/{}".format(self.id, epub_id),
_kwargs=combine_kwargs(**kwargs),
)
return CourseEpubExport(self._requester, response.json())