Example #1
0
 def test_accepted_history_with_note(self):
     add_applicant_note(self.applicant.id,
                        "A note",
                        title='A Title',
                        is_chat_log=True,
                        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']), 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'], 'accepted')
     self.assertEqual(len(app_data['notes']), 2)
     note_data = app_data['notes'][0]
     self.assertEqual(note_data['text'], 'A note')
     self.assertEqual(note_data['title'], 'A Title')
     self.assertEqual(note_data['author'], self.recruiter.name)
     self.assertTrue(note_data['is_chat_log'])
     for key in ('timestamp', 'author', 'title', 'text', 'id',
                 'is_chat_log'):
         self.assertIn(key, note_data)
Example #2
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)
Example #3
0
 def test_claimed_history_senior_recruiter_access(self):
     result = application_history(self.applicant.id,
                                  current_user=self.senior_recruiter)
     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'], 'claimed')
     self.assertEqual(len(app_data['notes']), 0)
Example #4
0
 def test_submitted_history(self):
     self.application.recruiter_id = None
     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'], None)
     self.assertEqual(app_data['recruiter_name'], None)
     self.assertEqual(app_data['status'], 'submitted')
     self.assertEqual(len(app_data['notes']), 0)
Example #5
0
def api_application_history(applicant_id):
    """
    Return application history for a user.

    Returned data is a list of dictionaries, one dict per application
    containing all relevant application data.

    Args:
        applicant_id (int): User key of applicant

    Returns:
        response

    Example:

    {
        'info': {
            <application_id>:
            {
                'recruiter_id': 10233421,  # could be None
                'recruiter_name': 'Recruiter Rachel',  # could be None
                'status': 'rejected',  # one of 'new', 'submitted', 'claimed, 'rejected', 'accepted', 'invited'
                'image_count': 1,  # number of uploaded screenshots
                'notes': [
                    {
                        "timestamp": "ISO Date string",
                        "author": "Recruiter Rachel",
                        "is_chat_log": True,
                        "id": 101052109,
                        "title": "Chat log from friday",
                        "text": "kiugoiugnboyiug ouiguy",
                    },
                    (...)
                ],
            },
            (...)
        }
    }

    Error codes:
        Forbidden (403): If logged in user is not a recruiter with access
            to the applicant, or a senior recruiter, or an admin.
    """
    return jsonify(application_history(applicant_id,
                                       current_user=current_user))
Example #6
0
 def test_empty_history(self):
     result = application_history(self.not_applicant.id,
                                  current_user=self.admin)
     self.assertIsInstance(result, dict)
     self.assertIn('info', result)
     self.assertEqual(len(result['info']), 0)