def test_add_to_section_makes_sdk_call_with_correct_params(self, add_to_section_replacement):
     """
     Assert that the enrollments.enroll_user_sections SDK method is being called with the expected parameters
     """
     request = self.add_to_section_stub()
     add_to_section(request)
     user_to_add = self.add_to_section_stub_body['users_to_add'][0]
     add_to_section_replacement.assert_any_call(
         ANY,
         self.add_to_section_stub_body['section_id'],
         user_to_add['enrollment_user_id'],
         enrollment_type=user_to_add['enrollment_type'],
         enrollment_role_id=user_to_add['enrollment_role_id'],
         enrollment_enrollment_state='active',
     )
Beispiel #2
0
 def test_add_to_section_makes_sdk_call_with_correct_params(
         self, add_to_section_replacement):
     """
     Assert that the enrollments.enroll_user_sections SDK method is being called with the expected parameters
     """
     request = self.add_to_section_stub()
     add_to_section(request)
     user_to_add = self.add_to_section_stub_body['users_to_add'][0]
     add_to_section_replacement.assert_any_call(
         ANY,
         self.add_to_section_stub_body['section_id'],
         user_to_add['enrollment_user_id'],
         enrollment_type=user_to_add['enrollment_type'],
         enrollment_role_id=user_to_add['enrollment_role_id'],
         enrollment_enrollment_state='active',
     )
 def test_add_to_section_success_on_enroll_user_sections_returning_200(self, logger_replacement,
                                                                       add_to_section_replacement):
     """ Assert that when SDK method returns success, then remove_section returns correct status code """
     request = self.add_to_section_stub()
     response = add_to_section(request)
     add_to_section_replacement.return_value.status_code = 200
     self.assertEqual(response.status_code, 200)
Beispiel #4
0
 def test_add_to_section_success_on_enroll_user_sections_returning_200(
         self, logger_replacement, add_to_section_replacement):
     """ Assert that when SDK method returns success, then remove_section returns correct status code """
     request = self.add_to_section_stub()
     response = add_to_section(request)
     add_to_section_replacement.return_value.status_code = 200
     self.assertEqual(response.status_code, 200)
 def test_add_to_section_logs_exception_on_failure_status_code(
         self, log_replacement, add_to_section_replacement):
     """ Assert that logger is logging an exception when return from backend
     is status code 4XX """
     request = self.add_to_section_stub()
     add_to_section_replacement.side_effect = CanvasAPIError()
     response = add_to_section(request)
     assert log_replacement.called
     self.assertEqual(len(json.loads(response.content)['failed']), 2)
 def test_add_to_section_raises_exception_on_missing_section_id(self, log_replacement, add_to_section_replacement):
     """ Assert that add_to_section returns a 500 response on missing section id   """
     request = self.add_to_section_stub()
     request_body = copy.deepcopy(self.add_to_section_stub_body)
     del request_body['section_id']
     request.body = json.dumps(request_body)
     response = add_to_section(request)
     assert log_replacement.called
     self.assertEqual(response.status_code, 500)
Beispiel #7
0
 def test_add_to_section_logs_exception_on_failure_status_code(
         self, log_replacement, add_to_section_replacement):
     """ Assert that logger is logging an exception when return from backend
     is status code 4XX """
     request = self.add_to_section_stub()
     add_to_section_replacement.side_effect = CanvasAPIError()
     response = add_to_section(request)
     assert log_replacement.called
     self.assertEqual(len(json.loads(response.content)['failed']), 2)
 def test_add_to_section_raises_exception_on_missing_enrollment_id(self, log_replacement,
                                                                   add_to_section_replacement):
     """ Assert that add_to_section returns a 500 response when the enrollment_user_id is missing """
     request = self.add_to_section_stub()
     request_body = copy.deepcopy(self.add_to_section_stub_body)
     del request_body['users_to_add'][0]['enrollment_user_id']
     request.body = json.dumps(request_body)
     response = add_to_section(request)
     assert log_replacement.called
     self.assertEqual(len(json.loads(response.content)['failed']), 1)
Beispiel #9
0
 def test_add_to_section_raises_exception_on_missing_enrollment_id(
         self, log_replacement, add_to_section_replacement):
     """ Assert that add_to_section returns a 500 response when the enrollment_user_id is missing """
     request = self.add_to_section_stub()
     request_body = copy.deepcopy(self.add_to_section_stub_body)
     del request_body['users_to_add'][0]['enrollment_user_id']
     request.body = json.dumps(request_body)
     response = add_to_section(request)
     assert log_replacement.called
     self.assertEqual(len(json.loads(response.content)['failed']), 1)
Beispiel #10
0
 def test_add_to_section_raises_exception_on_missing_section_id(
         self, log_replacement, add_to_section_replacement):
     """ Assert that add_to_section returns a 500 response on missing section id   """
     request = self.add_to_section_stub()
     request_body = copy.deepcopy(self.add_to_section_stub_body)
     del request_body['section_id']
     request.body = json.dumps(request_body)
     response = add_to_section(request)
     assert log_replacement.called
     self.assertEqual(response.status_code, 500)