コード例 #1
0
ファイル: test_serializers.py プロジェクト: giuse88/seevcam
 def test_candidate_deserializer(self):
     create_uploaded_file(self.user)
     candidate_json = b'{"id": 2, "name": "giuseppe", "email": "*****@*****.**", "surname": "pes", "cv" : 2}'
     stream = BytesIO(candidate_json)
     data = JSONParser().parse(stream)
     serializer = CandidateSerializer(data=data)
     self.assertTrue(serializer.is_valid())
コード例 #2
0
ファイル: test_notes_model.py プロジェクト: giuse88/seevcam
 def setUp(self):
     self.company = create_company()
     self.user = create_user(self.company)
     self.catalogue = create_catalogue(self.user)
     self.question = create_question(self.catalogue)
     self.job_position = create_job_position(self.user, self.company, create_uploaded_file(self.user))
     self.candidate = create_candidate(self.user, self.company, create_uploaded_file(self.user))
     self.interview = create_interview(self.user, self.catalogue, self.candidate, self.job_position)
コード例 #3
0
ファイル: test_serializers.py プロジェクト: giuse88/seevcam
 def test_job_position_deserialization(self):
     create_uploaded_file(self.user)
     job_spec_json = b'{"id": 2, "position": "text", "job_description": 2}'
     stream = BytesIO(job_spec_json)
     data = JSONParser().parse(stream)
     serializer = JobPositionSerializer(data=data)
     print(serializer.errors)
     self.assertTrue(serializer.is_valid())
コード例 #4
0
 def setUp(self):
     self.client = APIClient()
     self.company = create_company()
     self.user = create_user(self.company)
     self.catalogue = create_catalogue(self.user)
     self.question = create_question(self.catalogue)
     self.job_position = create_job_position(self.user, self.company, create_uploaded_file(self.user))
     self.candidate = create_candidate(self.user, self.company, create_uploaded_file(self.user))
     self.interview = create_interview(self.user, self.catalogue, self.candidate, self.job_position)
     InterviewList.create_interview_session = self.fake_session
コード例 #5
0
 def setUp(self):
     self.client = APIClient()
     self.company = create_company()
     self.user = create_user(self.company)
     self.catalogue = create_catalogue(self.user)
     self.question = create_question(self.catalogue)
     self.job_position = create_job_position(
         self.user, self.company, create_uploaded_file(self.user))
     self.candidate = create_candidate(self.user, self.company,
                                       create_uploaded_file(self.user))
     self.interview = create_interview(self.user, self.catalogue,
                                       self.candidate, self.job_position)
     InterviewList.create_interview_session = lambda x: "test_session"
     InterviewRoomView.generate_opentok_token = lambda x, y: "test_token"
コード例 #6
0
ファイル: test_rest_api.py プロジェクト: giuse88/seevcam
 def setUp(self):
     self.client = APIClient()
     self.company = create_company()
     self.user = create_user(self.company)
     self.catalogue = create_catalogue(self.user)
     self.question = create_question(self.catalogue)
     self.job_position = create_job_position(
         self.user, self.company, create_uploaded_file(self.user))
     self.candidate = create_candidate(self.user, self.company,
                                       create_uploaded_file(self.user))
     self.interview = create_interview(self.user, self.catalogue,
                                       self.candidate, self.job_position)
     self.url = '/dashboard/interviews/' + str(
         self.interview.id) + '/events/'
コード例 #7
0
ファイル: test_serializers.py プロジェクト: giuse88/seevcam
 def test_interview_deserialization(self):
     create_uploaded_file(self.user)
     json = b'{"id": 1, ' \
            b' "start": "2015-05-04T12:20:34.000343+0000", ' \
            b' "end": "2015-05-04T12:21:34.000343+0000", ' \
            b' "status": "OPEN", ' \
            b' "job_position": 1,' \
            b' "candidate": {"id": 1, "name": "giuseppe", "email": "*****@*****.**", "surname": "pes", "cv": 2},' \
            b' "overall_score": 0,'\
            b' "catalogue": 1}'
     stream = BytesIO(json)
     data = JSONParser().parse(stream)
     serializer = InterviewSerializer(data=data)
     print(serializer)
     self.assertTrue(serializer.is_valid())
コード例 #8
0
 def test_user_can_create_an_interview(self):
     cv = create_uploaded_file(self.user)
     self.client.force_authenticate(user=self.user)
     interview_json = {"start": "2015-05-04T12:20:34.0+0000",
                       "end": "2015-05-04T13:20:34.0+0000",
                       "status": "OPEN",
                       "job_position": 1,
                       "overall_score": 2,
                       "candidate": {"name": "giuseppe", "email": "*****@*****.**", "surname": "pes", "cv": cv.id},
                       "catalogue": 1}
     response = self.client.post("/dashboard/interviews/interviews/", interview_json, format='json')
     print(response.content)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
コード例 #9
0
ファイル: test_serializers.py プロジェクト: giuse88/seevcam
 def test_interview_deserialization_when_datetime_is_not_iso8610(self):
     create_uploaded_file(self.user)
     json = b'{"id": 1, ' \
            b' "start": "2014-12-23T11:30", ' \
            b' "end": "2014-12-23T12:00", ' \
            b' "status": "OPEN", ' \
            b' "job_position": 1,' \
            b' "candidate": {"id": 1, "name": "giuseppe", "email": "*****@*****.**", "surname": "pes", "cv": 2},' \
            b' "catalogue": 1}'
     stream = BytesIO(json)
     data = JSONParser().parse(stream)
     serializer = InterviewSerializer(data=data)
     self.assertFalse(serializer.is_valid())
     self.assertIsNotNone(serializer.errors['start'])
     self.assertEqual(
         serializer.errors['start'][0],
         'Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm:ss.uuuuuu[+HHMM|-HHMM]'
     )
     self.assertIsNotNone(serializer.errors['end'])
     self.assertEqual(
         serializer.errors['end'][0],
         'Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm:ss.uuuuuu[+HHMM|-HHMM]'
     )
コード例 #10
0
 def test_user_cannot_create_an_interview_with_incorrect_times(self):
     cv = create_uploaded_file(self.user)
     self.client.force_authenticate(user=self.user)
     interview_json = {"start": "2014-12-23T11:30:00Z",
                       "end": "2014-12-23T12:00:00Z",
                       "status": "OPEN",
                       "job_position": 1,
                       "candidate": {"name": "giuseppe", "email": "*****@*****.**", "surname": "pes", "cv": cv.id},
                       "catalogue": 1}
     response = self.client.post("/dashboard/interviews/interviews/", interview_json, format='json')
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertIsNotNone(response.data['start'][0])
     self.assertEqual(response.data['start'][0],
                      'Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm:ss.uuuuuu[+HHMM|-HHMM]')
     self.assertIsNotNone(response.data['end'][0])
     self.assertEqual(response.data['end'][0],
                      'Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm:ss.uuuuuu[+HHMM|-HHMM]')
コード例 #11
0
ファイル: test_serializers.py プロジェクト: giuse88/seevcam
    def setUp(self):
        self.company = Company(name="test")
        self.company.save()

        self.user = create_user(self.company, '*****@*****.**', 'test')

        self.uploaded_file = create_uploaded_file(self.user)

        self.candidate = Candidate(pk=1,
                                   created_by=self.user,
                                   company=self.company,
                                   name='giuseppe',
                                   surname='pes',
                                   email='*****@*****.**',
                                   cv=self.uploaded_file)
        self.candidate.save()

        self.catalogue = QuestionCatalogue(catalogue_name='test',
                                           catalogue_owner=self.user)
        self.catalogue.save()

        self.job_position = JobPosition(pk=1,
                                        position='text',
                                        company=self.company,
                                        created_by=self.user,
                                        job_description=self.uploaded_file)
        self.job_position.save()

        self.interview = Interview(pk=1,
                                   status=Interview.OPEN,
                                   start='2014-12-23 11:30',
                                   end='2014-12-23 12:00',
                                   catalogue=self.catalogue,
                                   owner=self.user,
                                   candidate=self.candidate,
                                   job_position=self.job_position)
        self.interview.save()
コード例 #12
0
ファイル: uploaded_files.py プロジェクト: giuse88/seevcam
def upload_job_spec(user):
    job = open_file("fixtures/files/job.pdf")
    uploaded_file = utils.create_uploaded_file(user, job, "jobSpec")
    uploaded_file.original_name = "JobPosition.pdf"
    uploaded_file.save()
    return uploaded_file
コード例 #13
0
ファイル: uploaded_files.py プロジェクト: giuse88/seevcam
def upload_cv(user):
    cv = open_file("fixtures/files/cv.pdf")
    uploaded_file = utils.create_uploaded_file(user, cv, "cv")
    uploaded_file.original_name = "CurriculumVitae.pdf"
    uploaded_file.save()
    return uploaded_file
コード例 #14
0
    def test_user_cannot_create_an_interview_with_end_before_start(self):
        cv = create_uploaded_file(self.user)
        self.client.force_authenticate(user=self.user)
        interview_json = {"start": "2015-06-04T16:20:34.0+0000",
                          "end": "2015-06-04T13:20:34.0+0000",
                          "status": "OPEN",
                          "job_position": 1,
                          "candidate": {"name": "giuseppe", "email": "*****@*****.**", "surname": "pes", "cv": cv.id},
                          "catalogue": 1}
        response = self.client.post("/dashboard/interviews/interviews/", interview_json, format='json')
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertIsNotNone(response.data['non_field_errors'])
        self.assertEqual(response.data['non_field_errors'][0], 'End must be after than start.')

    # def _test_a_users_cannot_schedule_two_interview_at_the_same_time(self):
    #     #
    #     self.lib.login(username='******', password='******')
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:00")
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 1)
    #     self.assertEqual(Interview.objects.count(), 1)
    #     interview_1 = Interview.objects.get(pk=1)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)
    #     #
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:00")
    #     print response
    #     self.assertTrue('Another interview has already been scheduled for the date selected' in response.content)
    #     self.assertEqual(response.status_code, status.HTTP_200_OK)
    #
    # def _test_overlapping_interviews_1(self):
    #     #
    #     self.lib.login(username='******', password='******')
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:00", 30)
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 1)
    #     self.assertEqual(Interview.objects.count(), 1)
    #     interview_1 = Interview.objects.get(pk=1)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)
    #     #
    #     response = self._create_interview(self._create_upload_file(), self._create_upload_file(),
    #                                       self.catalogue.id, "2030-1-1 11:05", 15)
    #     print response
    #     # self.assertTrue('Another interview has already been scheduled for the date selected' in response.content)
    #     self.assertEqual(response.status_code, status.HTTP_200_OK)
    #
    # def _test_overlapping_interviews_2(self):
    #     #
    #     self.lib.login(username='******', password='******')
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:05", 15)
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 1)
    #     self.assertEqual(Interview.objects.count(), 1)
    #     interview_1 = Interview.objects.get(pk=1)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)
    #     #
    #     response = self._create_interview(self._create_upload_file(), self._create_upload_file(),
    #                                       self.catalogue.id, "2030-1-1 11:00", 30)
    #     print response
    #     # self.assertTrue('Another interview has already been scheduled for the date selected' in response.content)
    #     self.assertEqual(response.status_code, status.HTTP_200_OK)
    #
    # def _test_overlapping_interviews_3(self):
    #     #
    #     self.lib.login(username='******', password='******')
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:00", 30)
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 1)
    #     self.assertEqual(Interview.objects.count(), 1)
    #     interview_1 = Interview.objects.get(pk=1)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)
    #     #
    #     response = self._create_interview(self._create_upload_file(), self._create_upload_file(),
    #                                       self.catalogue.id, "2030-1-1 10:45", 30)
    #     print response
    #     self.assertTrue('Another interview has already been scheduled for the date selected' in response.content)
    #     self.assertEqual(response.status_code, status.HTTP_200_OK)
    #
    # def _test_overlapping_interviews_4(self):
    #     #
    #     self.lib.login(username='******', password='******')
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:00", 30)
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 1)
    #     self.assertEqual(Interview.objects.count(), 1)
    #     interview_1 = Interview.objects.get(pk=1)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)
    #     #
    #     response = self._create_interview(self._create_upload_file(), self._create_upload_file(),
    #                                       self.catalogue.id, "2030-1-1 11:15", 30)
    #     print response
    #     self.assertTrue('Another interview has already been scheduled for the date selected' in response.content)
    #     self.assertEqual(response.status_code, status.HTTP_200_OK)
    #
    # def _test_overlapping_interviews_correct(self):
    #     #
    #     self.lib.login(username='******', password='******')
    #     response = self._create_interview(self.file_cv, self.file_job, self.catalogue.id, "2030-1-1 11:00", 30)
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 1)
    #     self.assertEqual(Interview.objects.count(), 1)
    #     interview_1 = Interview.objects.get(pk=1)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)
    #     #
    #     response = self._create_interview(self._create_upload_file(), self._create_upload_file(),
    #                                       self.catalogue.id, "2030-1-1 11:30", 30)
    #     self.assertEqual(response.status_code, status.HTTP_302_FOUND)
    #     self.assertEqual(Interview.objects.filter(interview_owner=self.user_1).count(), 2)
    #     self.assertEqual(Interview.objects.count(), 2)
    #     interview_1 = Interview.objects.get(pk=2)
    #     self.assertEqual(interview_1.candidate_name, "name")
    #     self._remove_uploaded_files(interview_1)