Ejemplo n.º 1
0
 def test_get_applicant_notes_forbidden(self):
     add_applicant_note(self.applicant.id,
                        "A note",
                        current_user=self.recruiter)
     for user in (self.other_recruiter, self.not_applicant):
         with self.assertRaises(ForbiddenException):
             get_applicant_notes(self.applicant.id, current_user=user)
Ejemplo n.º 2
0
 def test_get_another_recruiters_note(self):
     add_applicant_note(self.applicant.id,
                        "A note",
                        current_user=self.senior_recruiter)
     notes = get_applicant_notes(self.applicant.id,
                                 current_user=self.senior_recruiter)['info']
     self.assertEqual(notes[0]['can_edit'], True)
     other_view_of_notes = get_applicant_notes(
         self.applicant.id, current_user=self.recruiter)['info']
     self.assertEqual(other_view_of_notes[0]['can_edit'], False)
Ejemplo n.º 3
0
 def test_senior_recruiter_modify_own_note(self):
     add_applicant_note(self.applicant.id,
                        'A note',
                        current_user=self.senior_recruiter)
     note_data = get_applicant_notes(
         self.applicant.id, current_user=self.senior_recruiter)['info'][0]
     edit_applicant_note(note_data['id'],
                         'Edited note',
                         current_user=self.senior_recruiter)
     new_note_data = get_applicant_notes(
         self.applicant.id, current_user=self.senior_recruiter)['info'][0]
     self.assertEqual(note_data['id'], new_note_data['id'])
     self.assertEqual(new_note_data['text'], 'Edited note')
Ejemplo n.º 4
0
def api_get_applicant_notes_and_logs(applicant_id):
    """
    Get notes and chat logs for current application of an applicant.

    Args:
        applicant_id (int)

    Returns:
        response

    Example:
        {
        "info": [
            {
                "timestamp": "ISO Date string",
                "author": "Tommy Tattle",
                "can_edit": True,
                "is_chat_log": True,
                "id": 101052109,
                "title": "Chat log from friday",
                "text": "kiugoiugnboyiug ouiguy gkuyf jtf kuf kuyf kutf ikufk uyfku fkj iy gkuyg iuy guy kuy uky kuyg kuy iuy",
            },
        ]
        }
    """
    return jsonify(get_applicant_notes(applicant_id,
                                       current_user=current_user))
Ejemplo n.º 5
0
 def test_modify_own_note_title(self):
     add_applicant_note(self.applicant.id,
                        'A note',
                        title='Title',
                        current_user=self.senior_recruiter)
     note_data = get_applicant_notes(
         self.applicant.id, current_user=self.senior_recruiter)['info'][0]
     response = edit_applicant_note(note_data['id'],
                                    'Edited note',
                                    title='New Title',
                                    current_user=self.senior_recruiter)
     self.assertEqual(response, {'status': 'ok'})
     new_note_data = get_applicant_notes(
         self.applicant.id, current_user=self.senior_recruiter)['info'][0]
     self.assertEqual(note_data['id'], new_note_data['id'])
     self.assertEqual(new_note_data['title'], 'New Title')
     self.assertEqual(new_note_data['text'], 'Edited note')
Ejemplo n.º 6
0
 def test_cannot_modify_others_note(self):
     add_applicant_note(self.applicant.id,
                        'A note',
                        current_user=self.senior_recruiter)
     note_data = get_applicant_notes(
         self.applicant.id, current_user=self.senior_recruiter)['info'][0]
     with self.assertRaises(ForbiddenException):
         edit_applicant_note(note_data['id'],
                             'Edited note',
                             current_user=self.recruiter)
Ejemplo n.º 7
0
 def test_edit_note_forbidden(self):
     add_applicant_note(self.applicant.id,
                        'A note',
                        title='Title',
                        current_user=self.recruiter)
     note_data = get_applicant_notes(self.applicant.id,
                                     current_user=self.recruiter)['info'][0]
     for user in (self.applicant, self.not_applicant, self.other_recruiter):
         with self.assertRaises(ForbiddenException):
             edit_applicant_note(note_data['id'],
                                 'Edited note',
                                 title='New Title',
                                 current_user=user)
Ejemplo n.º 8
0
 def test_get_applicant_notes_without_title(self):
     add_applicant_note(self.applicant.id,
                        "A note",
                        current_user=self.recruiter)
     response = get_applicant_notes(self.applicant.id,
                                    current_user=self.recruiter)
     self.assertIsInstance(response, dict)
     self.assertIn('info', response)
     self.assertEqual(len(response['info']), 1)
     data = response['info'][0]
     for key in ('timestamp', 'author', 'title', 'text', 'id',
                 'is_chat_log'):
         self.assertIn(key, data)
     self.assertEqual(data['title'], None)
     self.assertEqual(data['text'], 'A note')
     self.assertEqual(data['is_chat_log'], False)
Ejemplo n.º 9
0
 def test_add_applicant_note_as_senior_recruiter(self):
     response = add_applicant_note(self.applicant.id,
                                   "A note",
                                   current_user=self.recruiter)
     self.assertDictEqual(response, {'status': 'ok'})
     notes = self.application.notes
     self.assertEqual(len(notes), 1)
     self.assertEqual(notes[0].text, "A note")
     augmented_notes = get_applicant_notes(
         self.applicant.id, current_user=self.recruiter)['info']
     self.assertEqual(augmented_notes[0]['can_edit'], True)
     response = add_applicant_note(self.applicant.id,
                                   "Another note",
                                   current_user=self.senior_recruiter)
     self.assertDictEqual(response, {'status': 'ok'})
     notes = self.application.notes
     self.assertEqual(len(notes), 2)
Ejemplo n.º 10
0
 def test_add_chat_log_with_title(self):
     response = add_applicant_note(self.applicant.id,
                                   "A note",
                                   title="A Title",
                                   is_chat_log=True,
                                   current_user=self.recruiter)
     self.assertDictEqual(response, {'status': 'ok'})
     notes = self.application.notes
     self.assertEqual(len(notes), 1)
     self.assertEqual(notes[0].text, "A note")
     self.assertEqual(notes[0].title, "A Title")
     augmented_notes = get_applicant_notes(
         self.applicant.id, current_user=self.recruiter)['info']
     self.assertEqual(augmented_notes[0]['can_edit'], True)
     response = add_applicant_note(self.applicant.id,
                                   "Another note",
                                   current_user=self.recruiter)
     self.assertDictEqual(response, {'status': 'ok'})
     notes = self.application.notes
     self.assertEqual(len(notes), 2)