def test_applicant_list_after_rejection(self): self.application.is_submitted = True db.session.commit() reject_applicant(self.applicant.id, current_user=self.recruiter) applicant_list = get_applicant_list(current_user=self.recruiter)[ 'info'] self.assertEqual(len(applicant_list), 0) applicant_list = get_applicant_list(current_user=self.senior_recruiter)['info'] self.assertEqual(len(applicant_list), 0)
def test_two_applications(self): reject_applicant(self.applicant.id, current_user=self.recruiter) start_application(self.applicant) submit_application(self.applicant) claim_applicant(self.applicant.id, current_user=self.recruiter) accept_applicant(self.applicant.id, current_user=self.recruiter) result = application_history(self.applicant.id, current_user=self.admin) self.assertIsInstance(result, dict) self.assertIn('info', result) self.assertIsInstance(result['info'], dict) self.assertEqual(len(result['info']), 2)
def test_rejected_history(self): reject_applicant(self.applicant.id, current_user=self.recruiter) result = application_history(self.applicant.id, current_user=self.admin) self.assertIsInstance(result, dict) self.assertIn('info', result) self.assertIsInstance(result['info'], dict) self.assertEqual(len(result['info']), 1) the_key = list(result['info'].keys())[0] app_data = result['info'][the_key] self.assertEqual(app_data['recruiter_id'], self.recruiter.id) self.assertEqual(app_data['recruiter_name'], self.recruiter.name) self.assertEqual(app_data['status'], 'rejected') self.assertEqual(len(app_data['notes']), 1)
def test_sr_reject_accepted_applicant(self): self.assertEqual(len(self.application.notes), 0) claim_applicant(self.applicant.id, current_user=self.recruiter) self.assertEqual(len(self.application.notes), 1) accept_applicant(self.applicant.id, current_user=self.recruiter) self.assertEqual(len(self.application.notes), 2) response = reject_applicant(self.applicant.id, current_user=self.senior_recruiter) self.assertEqual(len(self.application.notes), 3) self.assertDictEqual(response, {'status': 'ok'}) self.assertFalse(self.application.is_accepted) self.assertTrue(self.application.is_concluded) self.assertFalse(self.application.is_invited)
def api_reject_applicant(applicant_id): """ Sets an applicant's status to "rejected". Args: applicant_id (int): User key of applicant Returns: {'status': 'ok'} if applicant is successfully rejected Error codes: Forbidden (403): If logged in user is not a senior recruiter or a recruiter who has claimed this applicant (including if they are not an applicant). """ return jsonify(reject_applicant(applicant_id, current_user=current_user))
def test_start_new_application_after_rejection(self): reject_applicant(self.applicant.id, self.recruiter) start_application(self.applicant) application = Application.get_for_user(self.applicant.id) self.assertIsInstance(application, Application) self.assertEqual(application.user_id, self.applicant.id)
def test_invite_rejected_applicant(self): claim_applicant(self.applicant.id, current_user=self.recruiter) reject_applicant(self.applicant.id, current_user=self.recruiter) with self.assertRaises(BadRequestException): invite_applicant(self.applicant.id, current_user=self.senior_recruiter)
def test_reject_applicant_as_admin(self): claim_applicant(self.applicant.id, current_user=self.recruiter) with self.assertRaises(ForbiddenException): reject_applicant(self.applicant.id, current_user=self.admin)
def test_reject_applicant_as_senior_recruiter(self): claim_applicant(self.applicant.id, current_user=self.recruiter) response = reject_applicant(self.applicant.id, current_user=self.recruiter) self.assertDictEqual(response, {'status': 'ok'}) self.assertFalse(self.application.is_accepted) self.assertTrue(self.application.is_concluded)
def test_reject_not_applicant(self): with self.assertRaises(ForbiddenException): reject_applicant(self.not_applicant.id, current_user=self.recruiter)
def test_sr_reject_invited_applicant_forbidden(self): claim_applicant(self.applicant.id, current_user=self.recruiter) accept_applicant(self.applicant.id, current_user=self.recruiter) invite_applicant(self.applicant.id, current_user=self.senior_recruiter) with self.assertRaises(ForbiddenException): reject_applicant(self.applicant.id, current_user=self.senior_recruiter)