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_edit_appointment_group_fail(self, m):
with self.assertRaises(RequiredFieldMissing):
self.appointment_group.edit({})
def test_edit(self, m):
register_uris({"user": ["edit"]}, m)
new_name = "New User Name"
self.user.edit(user={"name": new_name})
self.assertIsInstance(self.user, User)
self.assertTrue(hasattr(self.user, "name"))
self.assertEqual(self.user.name, new_name)
def test_edit_assignment(self, m):
register_uris({"assignment": ["edit_assignment"]}, m)
name = "New Name"
edited_assignment = self.assignment.edit(assignment={"name": name})
self.assertIsInstance(edited_assignment, Assignment)
self.assertTrue(hasattr(edited_assignment, "name"))
self.assertEqual(edited_assignment.name, name)
def test_edit(self, m):
register_uris({"submission": ["edit"]}, m)
self.assertFalse(hasattr(self.submission_course, "excused"))
self.submission_course.edit(submission={"excuse": True})
self.assertIsInstance(self.submission_course, Submission)
self.assertTrue(hasattr(self.submission_course, "excused"))
self.assertTrue(self.submission_course.excused)
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 test_get_submissions(self, m):
register_uris({"quiz": ["get_all_quiz_submissions"]}, m)
submissions = self.quiz.get_submissions()
self.assertIsInstance(submissions, PaginatedList)
submission_list = [sub for sub in submissions]
self.assertEqual(len(submission_list), 2)
self.assertIsInstance(submission_list[0], QuizSubmission)
self.assertEqual(submission_list[0].id, 1)
self.assertTrue(hasattr(submission_list[0], "attempt"))
self.assertEqual(submission_list[0].attempt, 3)
self.assertIsInstance(submission_list[1], QuizSubmission)
self.assertEqual(submission_list[1].id, 2)
self.assertTrue(hasattr(submission_list[1], "score"))
self.assertEqual(submission_list[1].score, 5)
def test_obj_or_id_str_invalid(self, m):
with self.assertRaises(TypeError):
obj_or_id("1a", "user_id", (User,))
def test_init_warns_when_url_is_http(self, m):
with warnings.catch_warnings(record=True):
Canvas(settings.BASE_URL_AS_HTTP, settings.API_KEY)
self.assertRaises(
UserWarning,
msg=(
"Canvas may respond unexpectedly when making requests to HTTP"
"URLs. If possible, please use HTTPS."
def setUp(self):
self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)
self.outcome_import = OutcomeImport(
self.canvas._Canvas__requester, {"id": 1, "workflow_state": 1}
)
def setUp(self):
self.canvas = Canvas(settings.BASE_URL, settings.API_KEY)