def test_remove_section_throws_exception_when_get_section_fails( self, get_section_replacement, is_editable_section_replacement, delete_section_replacement): """ Assert that an exception is raised when get_section_by_id fails making SDK call """ request = self.delete_section_stub() get_section_replacement.return_value = None response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 500)
def test_remove_section_throws_exception_when_get_section_fails(self, get_section_replacement, is_editable_section_replacement, delete_section_replacement): """ Assert that an exception is raised when get_section_by_id fails making SDK call """ request = self.delete_section_stub() get_section_replacement.return_value = None response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 500)
def test_remove_section_for_non_editable_section_fails(self, log_replacement, get_section_replacement, is_editable_section_replacement): """ Status 422 should be returned for a primary or registrar section """ request = self.delete_section_stub() request.sis_section_id = '123456' get_section_replacement.return_value = DEFAULT is_editable_section_replacement.return_value = False response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 422)
def test_remove_section_for_primary_section_fails(self, log_replacement, get_section_replacement, is_editable_section_replacement): """ Assert that status code 422 is returned when section is a primary section """ request = self.delete_section_stub() request.sis_section_id = '123456' get_section_replacement.return_value = DEFAULT is_editable_section_replacement.return_value = False response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 422)
def test_remove_section_success_on_delete_section_returning_200(self, get_section_replacement, is_editable_section_replacement, delete_section_replacement, render_replacement): """ Assert that when SDK method returns sucess, then remove_section returns correct status code """ request = self.delete_section_stub() get_section_replacement.return_value = self.section is_editable_section_replacement.return_value = True delete_section_replacement.return_value = self.section response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 200)
def test_remove_section_logs_exception_on_failure_status_code(self, log_replacement, get_section_replacement, is_editable_section_replacement, delete_section_replacement): """ Assert that logger is logging an exception when return from backend is status code 4XX """ request = self.delete_section_stub() get_section_replacement.return_value = self.section is_editable_section_replacement.return_value = True delete_section_replacement.return_value = None response = remove_section(request, request.section_id) assert log_replacement.called
def test_remove_section_for_non_editable_section_fails( self, log_replacement, get_section_replacement, is_editable_section_replacement): """ Status 422 should be returned for a primary or registrar section """ request = self.delete_section_stub() request.sis_section_id = '123456' get_section_replacement.return_value = DEFAULT is_editable_section_replacement.return_value = False response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 422)
def test_remove_section_for_primary_section_fails( self, log_replacement, get_section_replacement, is_editable_section_replacement): """ Assert that status code 422 is returned when section is a primary section """ request = self.delete_section_stub() request.sis_section_id = '123456' get_section_replacement.return_value = DEFAULT is_editable_section_replacement.return_value = False response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 422)
def test_remove_section_success_on_delete_section_returning_200( self, get_section_replacement, is_editable_section_replacement, delete_section_replacement, render_replacement): """ Assert that when SDK method returns sucess, then remove_section returns correct status code """ request = self.delete_section_stub() get_section_replacement.return_value = self.section is_editable_section_replacement.return_value = True delete_section_replacement.return_value = self.section response = remove_section(request, request.section_id) self.assertEqual(response.status_code, 200)
def test_remove_section_logs_exception_on_failure_status_code( self, log_replacement, get_section_replacement, is_editable_section_replacement, delete_section_replacement): """ Assert that logger is logging an exception when return from backend is status code 4XX """ request = self.delete_section_stub() get_section_replacement.return_value = self.section is_editable_section_replacement.return_value = True delete_section_replacement.return_value = None response = remove_section(request, request.section_id) assert log_replacement.called