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_outcome_group(self, m):
register_uris({"outcome": ["canvas_get_outcome_group"]}, m)
outcome_group_by_id = self.canvas.get_outcome_group(1)
self.assertIsInstance(outcome_group_by_id, OutcomeGroup)
self.assertEqual(outcome_group_by_id.id, 1)
self.assertEqual(outcome_group_by_id.title, "Canvas outcome group title")
outcome_group_by_obj = self.canvas.get_outcome_group(outcome_group_by_id)
self.assertIsInstance(outcome_group_by_obj, OutcomeGroup)
self.assertEqual(outcome_group_by_obj.id, 1)
self.assertEqual(outcome_group_by_obj.title, "Canvas outcome group title")
self.assertEqual(result[1].id, 3)
self.assertEqual(result[1].title, "Global Listed Subgroup Title 2")
self.assertTrue(hasattr(result[0], 'context_type'))
self.assertEqual(result[0].context_type, None)
self.assertTrue(hasattr(result[0], 'context_id'))
self.assertEqual(result[0].context_id, None)
result = self.account_outcome_group.get_subgroups()
self.assertIsInstance(result[0], OutcomeGroup)
self.assertEqual(result[0].id, 2)
self.assertEqual(result[0].title, "Account Listed Subgroup Title 1")
self.assertTrue(hasattr(result[0], 'context_type'))
self.assertEqual(result[0].context_type, 'Account')
self.assertTrue(hasattr(result[0], 'context_id'))
self.assertEqual(result[0].context_id, self.account.id)
self.assertIsInstance(result[1], OutcomeGroup)
self.assertEqual(result[1].id, 3)
self.assertEqual(result[1].title, "Account Listed Subgroup Title 2")
self.assertTrue(hasattr(result[0], 'context_type'))
self.assertEqual(result[0].context_type, 'Account')
self.assertTrue(hasattr(result[0], 'context_id'))
self.assertEqual(result[0].context_id, self.account.id)
result = self.course_outcome_group.get_subgroups()
self.assertIsInstance(result[0], OutcomeGroup)
self.assertEqual(result[0].id, 2)
self.assertEqual(result[0].title, "Course Listed Subgroup Title 1")
self.assertTrue(hasattr(result[0], 'context_type'))
self.assertEqual(result[0].context_type, 'Course')
self.assertTrue(hasattr(result[0], 'context_id'))
self.assertEqual(result[0].context_id, self.course.id)
self.assertIsInstance(result[1], OutcomeGroup)
def test_get_outcome_group(self, m):
register_uris({"outcome": ["course_get_outcome_group"]}, m)
outcome_group_by_id = self.course.get_outcome_group(1)
self.assertIsInstance(outcome_group_by_id, OutcomeGroup)
self.assertEqual(outcome_group_by_id.id, 1)
self.assertEqual(outcome_group_by_id.title, "Course outcome group title")
outcome_group_by_obj = self.course.get_outcome_group(outcome_group_by_id)
self.assertIsInstance(outcome_group_by_obj, OutcomeGroup)
self.assertEqual(outcome_group_by_obj.id, 1)
self.assertEqual(outcome_group_by_obj.title, "Course outcome group title")
def test_get_outcome_group(self, m):
register_uris({"outcome": ["account_get_outcome_group"]}, m)
outcome_group_by_id = self.account.get_outcome_group(1)
self.assertIsInstance(outcome_group_by_id, OutcomeGroup)
self.assertEqual(outcome_group_by_id.id, 1)
self.assertEqual(outcome_group_by_id.title, "Account outcome group title")
outcome_group_by_obj = self.account.get_outcome_group(outcome_group_by_id)
self.assertIsInstance(outcome_group_by_obj, OutcomeGroup)
self.assertEqual(outcome_group_by_obj.id, 1)
self.assertEqual(outcome_group_by_obj.title, "Account outcome group title")
`_
or `DELETE /api/v1/accounts/:account_id/outcome_groups/:id \
`_
or `DELETE /api/v1/courses/:course_id/outcome_groups/:id \
`_
:returns: True if successful, false if failed.
:rtype: bool
"""
response = self._requester.request(
'DELETE',
'{}/outcome_groups/{}'.format(self.context_ref(), self.id)
)
if 'id' in response.json():
super(OutcomeGroup, self).set_attributes(response.json())
return 'id' in response.json()
def get_outcome_group(self, group):
"""
Returns the details of the Outcome Group with the given id.
:calls: `GET /api/v1/global/outcome_groups/:id \
`_
:param group: The outcome group object or ID to return.
:type group: :class:`canvasapi.outcome.OutcomeGroup` or int
:returns: An outcome group object.
:rtype: :class:`canvasapi.outcome.OutcomeGroup`
"""
from canvasapi.outcome import OutcomeGroup
outcome_group_id = obj_or_id(group, "group", (OutcomeGroup,))
response = self.__requester.request(
"GET", "global/outcome_groups/{}".format(outcome_group_id)
)
return OutcomeGroup(self.__requester, response.json())
def get_root_outcome_group(self):
"""
Redirect to root outcome group for context
:calls: `GET /api/v1/global/root_outcome_group \
`_
:returns: The OutcomeGroup of the context.
:rtype: :class:`canvasapi.outcome.OutcomeGroup`
"""
from canvasapi.outcome import OutcomeGroup
response = self.__requester.request("GET", "global/root_outcome_group")
return OutcomeGroup(self.__requester, response.json())
`_
or `GET /api/v1/accounts/:account_id/outcome_groups/:id \
`_
or `GET /api/v1/courses/:course_id/outcome_groups/:id \
`_
:returns: Linked outcome group object.
:rtype: :class:`canvasapi.outcome.OutcomeGroup`
"""
ogid = self.outcome_group['id']
response = self._requester.request(
'GET',
'{}/outcome_groups/{}'.format(self.context_ref(), ogid)
)
return OutcomeGroup(self._requester, response.json())
def get_root_outcome_group(self):
"""
Redirect to root outcome group for context
:calls: `GET /api/v1/courses/:course_id/root_outcome_group \
`_
:returns: The OutcomeGroup of the context.
:rtype: :class:`canvasapi.outcome.OutcomeGroup`
"""
from canvasapi.outcome import OutcomeGroup
response = self._requester.request(
"GET", "courses/{}/root_outcome_group".format(self.id)
)
return OutcomeGroup(self._requester, response.json())
`_
:param group: The outcome group object or ID to return.
:type group: :class:`canvasapi.outcome.OutcomeGroup` or int
:returns: An outcome group object.
:rtype: :class:`canvasapi.outcome.OutcomeGroup`
"""
from canvasapi.outcome import OutcomeGroup
outcome_group_id = obj_or_id(group, "outcome group", (OutcomeGroup,))
response = self._requester.request(
"GET", "accounts/{}/outcome_groups/{}".format(self.id, outcome_group_id)
)
return OutcomeGroup(self._requester, response.json())