Beispiel #1
0
    def test_delete_education_degree_of_a_different_candidate(
            self, access_token_first, talent_pool):
        """
        Test:   Attempt to delete the education-degrees of a different Candidate
        Expect: 403
        """
        # Create candidate_1 and candidate_2
        data_1 = generate_single_candidate_data([talent_pool.id])
        data_2 = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_1)
        candidate_1_id = create_resp.json()['candidates'][0]['id']
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_2)
        candidate_2_id = create_resp.json()['candidates'][0]['id']

        # Retrieve candidate_2's education degrees
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_2_id,
                                access_token_first)
        can_2_educations = get_resp.json()['candidate']['educations']

        # Delete candidate_2's id using candidate_1_id
        url = CandidateApiUrl.DEGREES % (candidate_1_id,
                                         can_2_educations[0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)
        assert updated_resp.status_code == 403
        assert updated_resp.json(
        )['error']['code'] == custom_error.EDUCATION_FORBIDDEN
Beispiel #2
0
    def test_delete_phone_of_a_different_candidate(self, access_token_first,
                                                   talent_pool):
        """
        Test:   Attempt to delete the phone of a different Candidate
        Expect: 403
        """
        # Create candidate_1 and candidate_2
        data_1 = generate_single_candidate_data([talent_pool.id])
        data_2 = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_1)
        candidate_1_id = create_resp.json()['candidates'][0]['id']
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_2)
        candidate_2_id = create_resp.json()['candidates'][0]['id']

        # Retrieve candidate_2's phones
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_2_id,
                                access_token_first)
        can_2_phones = get_resp.json()['candidate']['phones']

        # Delete candidate_2's id using candidate_1_id
        url = CandidateApiUrl.PHONE % (candidate_1_id, can_2_phones[0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)
        assert updated_resp.status_code == requests.codes.FORBIDDEN
        assert updated_resp.json(
        )['error']['code'] == custom_error.PHONE_FORBIDDEN
Beispiel #3
0
    def test_delete_preferred_location_of_a_different_candidate(
            self, access_token_first, talent_pool):
        """
        Test:   Attempt to delete the preferred location of a different Candidate
        Expect: 403
        """

        # Create candidate_1 and candidate_2
        data_1 = generate_single_candidate_data([talent_pool.id])
        data_2 = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_1)
        candidate_1_id = create_resp.json()['candidates'][0]['id']
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_2)
        candidate_2_id = create_resp.json()['candidates'][0]['id']

        # Retrieve candidate_2's preferred locations
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_2_id,
                                access_token_first)
        can_2_preferred_locationes = get_resp.json(
        )['candidate']['preferred_locations']

        # Delete candidate_2's id using candidate_1_id
        url = CandidateApiUrl.PREFERRED_LOCATION % (
            candidate_1_id, can_2_preferred_locationes[0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)
        assert updated_resp.status_code == 403
Beispiel #4
0
    def test_update_education_of_a_diff_candidate(self, access_token_first,
                                                  talent_pool):
        """
        Test:   Update education information of a different Candidate
        Expect: 403
        """

        # Create Candidate
        data_1 = generate_single_candidate_data([talent_pool.id])
        data_2 = generate_single_candidate_data([talent_pool.id])
        resp_1 = send_request('post', CandidateApiUrl.CANDIDATES,
                              access_token_first, data_1)
        resp_2 = send_request('post', CandidateApiUrl.CANDIDATES,
                              access_token_first, data_2)
        candidate_1_id = resp_1.json()['candidates'][0]['id']
        candidate_2_id = resp_2.json()['candidates'][0]['id']

        # Retrieve Candidate
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_1_id,
                                access_token_first)
        candidate_dict = get_resp.json()['candidate']

        # Update existing CandidateEducation of a different Candidate
        data = GenerateCandidateData.educations(
            candidate_id=candidate_2_id,
            education_id=candidate_dict['educations'][0]['id'])
        updated_resp = send_request('patch', CandidateApiUrl.CANDIDATES,
                                    access_token_first, data)
        print response_info(updated_resp)
        assert updated_resp.status_code == 403
        assert updated_resp.json(
        )['error']['code'] == custom_error.EDUCATION_FORBIDDEN
Beispiel #5
0
    def test_delete_can_edu_degree_bullets_of_a_different_candidate(
            self, access_token_first, talent_pool):
        """
        Test:   Attempt to delete degree-bullets of a different Candidate
        Expect: 403
        """
        # Create candidate_1 and candidate_2
        data_1 = generate_single_candidate_data([talent_pool.id])
        data_2 = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_1)
        candidate_1_id = create_resp.json()['candidates'][0]['id']
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data_2)
        candidate_2_id = create_resp.json()['candidates'][0]['id']

        # Retrieve candidate_2's degree-bullets
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_2_id,
                                access_token_first)
        can_2_edu = get_resp.json()['candidate']['educations'][0]
        can_2_edu_degree = can_2_edu['degrees'][0]
        can_2_edu_degree_bullet = can_2_edu['degrees'][0]['bullets'][0]

        # Delete candidate_2's degree bullet using candidate_1_id
        url = CandidateApiUrl.DEGREE_BULLET % (candidate_1_id, can_2_edu['id'],
                                               can_2_edu_degree['id'],
                                               can_2_edu_degree_bullet['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)
        assert updated_resp.status_code == 404
        assert updated_resp.json(
        )['error']['code'] == custom_error.DEGREE_NOT_FOUND
Beispiel #6
0
    def test_add_candidate_subscription_preference(self, access_token_first,
                                                   talent_pool):
        """
        Test: Add subscription preference for the candidate
        Expect: 204
        """
        # Create candidate and candidate subscription preference
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        candidate_id = create_resp.json()['candidates'][0]['id']
        data = {'frequency_id': 1}
        resp = send_request(
            'post', CandidateApiUrl.CANDIDATE_PREFERENCE % candidate_id,
            access_token_first, data)
        print response_info(resp)
        assert resp.status_code == 204

        # Retrieve Candidate's subscription preference
        resp = send_request(
            'get', CandidateApiUrl.CANDIDATE_PREFERENCE % candidate_id,
            access_token_first)
        print response_info(resp)
        assert resp.status_code == 200
        assert resp.json(
        )['candidate']['subscription_preference']['frequency_id'] == 1
Beispiel #7
0
    def test_delete_candidate_phone(self, access_token_first, talent_pool):
        """
        Test:   Remove Candidate's phone from db
        Expect: 204, Candidate's phones must be less 1
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate's phones
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_phones = get_resp.json()['candidate']['phones']

        # Current number of candidate's phones
        phones_count_before_delete = len(can_phones)

        # Delete Candidate's phone
        url = CandidateApiUrl.PHONE % (candidate_id, can_phones[0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate's phones after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_phones_after_delete = get_resp.json()['candidate']['phones']
        assert updated_resp.status_code == requests.codes.NO_CONTENT
        assert len(can_phones_after_delete) == phones_count_before_delete - 1
Beispiel #8
0
    def test_multiple_is_default_phones(self, access_token_first, talent_pool):
        """
        Test:   Add more than one CandidatePhone with is_default set to True
        Expect: 200, but only one CandidatePhone must have is_current True, the rest must be False
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Add a new email to the existing Candidate with is_current set to True
        candidate_id = create_resp.json()['candidates'][0]['id']
        send_request('patch', CandidateApiUrl.CANDIDATES, access_token_first,
                     data)

        # Retrieve Candidate after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        updated_candidate_dict = get_resp.json()['candidate']
        updated_can_phones = updated_candidate_dict['phones']

        # Only one of the phones must be default!
        assert sum([1 for phone in updated_can_phones
                    if phone['is_default']]) == 1
Beispiel #9
0
    def test_delete_degree_bullets_of_a_candidate_belonging_to_a_diff_user(
            self, access_token_first, talent_pool, access_token_second):
        """
        Test:   Attempt to delete degree-bullets of a Candidate that belongs to a user from a diff domain
        Expect: 204
        """

        # Create candidate_1 & candidate_2 with user_first & user_first_2
        data = generate_single_candidate_data([talent_pool.id])
        create_resp_1 = send_request('post', CandidateApiUrl.CANDIDATES,
                                     access_token_first, data)

        # Retrieve candidate_1
        candidate_1_id = create_resp_1.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_1_id,
                                access_token_first)
        can_1_educations = get_resp.json()['candidate']['educations']

        # Delete candidate_1's degree-bullets with user_first_2 logged in
        url = CandidateApiUrl.DEGREE_BULLETS % (
            candidate_1_id, can_1_educations[0]['id'],
            can_1_educations[0]['degrees'][0]['id'])
        updated_resp = send_request('delete', url, access_token_second)
        print response_info(updated_resp)
        assert updated_resp.status_code == 403
        assert updated_resp.json(
        )['error']['code'] == custom_error.CANDIDATE_FORBIDDEN
Beispiel #10
0
    def test_create_candidate_experience(self, access_token_first, talent_pool):
        """
        Test:   Create CandidateExperience for Candidate
        Expect: 201
        """

        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', self.CANDIDATES_URL, access_token_first, data)
        print response_info(create_resp)
        assert create_resp.status_code == self.CREATED

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get', self.CANDIDATE_URL % candidate_id, access_token_first)
        candidate_dict = get_resp.json()['candidate']

        # Assert data sent in = data retrieved
        can_experiences = candidate_dict['work_experiences']
        # order of data returned depends on experience's is_current, start_year, and start_month values, respectively
        order_work_experiences(data['candidates'][0]['work_experiences'])
        can_exp_data = data['candidates'][0]['work_experiences'][0]
        assert isinstance(can_experiences, list)

        assert can_experiences[0]['organization'] == can_exp_data['organization']
        assert can_experiences[0]['position'] == can_exp_data['position']
        assert can_experiences[0]['city'] == can_exp_data['city']
        assert can_experiences[0]['is_current'] == can_exp_data['is_current']

        can_exp_bullets = can_experiences[0]['bullets']
        assert isinstance(can_exp_bullets, list)
        assert can_exp_bullets[0]['description'] == can_exp_data['bullets'][0]['description']
Beispiel #11
0
    def test_delete_candidates_experience_bullet(self, access_token_first, talent_pool):
        """
        Test:   Remove Candidate's experience-bullet from db
        Expect: 204, Candidate's experience-bullet must be less 1; no experiences must be removed
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES, access_token_first, data)

        # Retrieve Candidate Experiences
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get', CandidateApiUrl.CANDIDATE % candidate_id, access_token_first)
        can_experiences = get_resp.json()['candidate']['work_experiences']

        # Current Number of can_experiences, and can_experiences' first bullets
        experience_count_before_deleting_bullets = len(can_experiences)
        experience_bullet_count_before_deleting = len(can_experiences[0]['bullets'])

        # Remove all of Candidate's experiences
        url = self.BULLET_URL % (candidate_id, can_experiences[0]['id'],
                                 can_experiences[0]['bullets'][0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get', CandidateApiUrl.CANDIDATE % candidate_id, access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == self.DELETED
        assert len(
            can_dict_after_update['work_experiences'][0]['bullets']) == experience_bullet_count_before_deleting - 1
        assert len(can_dict_after_update['work_experiences']) == experience_count_before_deleting_bullets
Beispiel #12
0
    def test_delete_candidate_experience(self, access_token_first, talent_pool):
        """
        Test:   Remove Candidate's experience from db
        Expect: 204, Candidate's experience must be less 1.
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', self.CANDIDATES_URL, access_token_first, data)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get', self.CANDIDATE_URL % candidate_id, access_token_first)
        candidate_dict = get_resp.json()['candidate']
        candidate_experiences = candidate_dict['work_experiences']

        # Current number of Candidate's experiences
        experiences_count_before_delete = len(candidate_experiences)

        # Remove one of Candidate's education
        exp_id = candidate_experiences[0]['id']
        updated_resp = send_request('delete', self.EXPERIENCE_URL % (candidate_id, exp_id), access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get', self.CANDIDATE_URL % candidate_id, access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == self.DELETED
        assert len(can_dict_after_update['work_experiences']) == experiences_count_before_delete - 1
Beispiel #13
0
    def test_delete_candidate_work_preference(self, access_token_first,
                                              talent_pool):
        """
        Test:   Remove Candidate's work-preference from db
        Expect: 204, Candidate must not have any work-preference left
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate's work preference
        candidate_id = create_resp.json()['candidates'][0]['id']

        # Delete Candidate's work preference
        updated_resp = send_request(
            'delete', CandidateApiUrl.WORK_PREFERENCES % candidate_id,
            access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == 204
        assert len(can_dict_after_update['work_preference']) == 0
Beispiel #14
0
    def test_delete_can_social_network(self, access_token_first, talent_pool):
        """
        Test:   Remove Candidate's social network from db
        Expect: 204, Candidate's social networks must be less 1
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate's social networks
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_sn = get_resp.json()['candidate']['social_networks']

        # Current number of candidate's social networks
        sn_count_before_delete = len(can_sn)

        # Delete Candidate's skill
        url = CandidateApiUrl.SOCIAL_NETWORK % (candidate_id, can_sn[0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate's social networks after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_sn_after_delete = get_resp.json()['candidate']['social_networks']
        assert updated_resp.status_code == 204
        assert len(can_sn_after_delete) == sn_count_before_delete - 1
Beispiel #15
0
    def test_delete_candidate_social_networks(self, access_token_first,
                                              talent_pool):
        """
        Test:   Remove Candidate's social networks from db
        Expect: 204, Candidate must not have any social networks left
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Delete Candidate's social networks
        candidate_id = create_resp.json()['candidates'][0]['id']
        updated_resp = send_request(
            'delete', CandidateApiUrl.SOCIAL_NETWORKS % candidate_id,
            access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == 204
        assert len(can_dict_after_update['social_networks']) == 0
Beispiel #16
0
    def test_create_candidate_educations_with_no_degrees(
            self, access_token_first, talent_pool):
        """
        Test:   Create CandidateEducation for Candidate
        Expect: 201
        """
        # Create Candidate without degrees
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(create_resp)
        assert create_resp.status_code == 201

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        candidate_dict = get_resp.json()['candidate']

        can_educations = candidate_dict['educations']
        data_educations = data['candidates'][0]['educations'][0]
        assert isinstance(can_educations, list)
        assert can_educations[0]['city'] == data_educations['city']
        assert can_educations[0]['school_name'] == data_educations[
            'school_name']

        can_edu_degrees = can_educations[0]['degrees']
        assert isinstance(can_edu_degrees, list)
Beispiel #17
0
    def test_create_candidate_photo(self, access_token_first, talent_pool):
        """
        Test: Create candidate photo
        Expect: 201
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(create_resp)
        assert create_resp.status_code == requests.codes.created

        # Add Photo to candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        data = {
            'photos': [{
                'image_url': 'www.foo.com',
                'added_time': datetime.isoformat(datetime.utcnow())
            }, {
                'image_url': 'www.goo.com'
            }]
        }
        create_photo = send_request('post',
                                    CandidateApiUrl.PHOTOS % candidate_id,
                                    access_token_first, data)
        print response_info(create_photo)
        assert create_photo.status_code == requests.codes.no_content

        # Retrieve candidate's photo
        get_resp = send_request('get', CandidateApiUrl.PHOTOS % candidate_id,
                                access_token_first)
        print response_info(get_resp)
        assert get_resp.status_code == requests.codes.ok
        assert len(get_resp.json()['candidate_photos']) == 2
Beispiel #18
0
    def test_delete_candidate_educations(self, access_token_first,
                                         talent_pool):
        """
        Test:   Remove all of candidate's educations from db
        Expect: 204, Candidate should not have any educations left
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Remove all of Candidate's educations
        candidate_id = create_resp.json()['candidates'][0]['id']
        updated_resp = send_request('delete',
                                    CandidateApiUrl.EDUCATIONS % candidate_id,
                                    access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == 204
        assert len(can_dict_after_update['educations']) == 0
Beispiel #19
0
    def test_create_duplicate_photos(self, access_token_first, talent_pool):
        """
        Test: Attempt to create two photos with the same url for the same candidate in the same domain
        Expect: 204, but duplicate image_url should not be inserted into the db
        """
        # Create candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(create_resp)
        assert create_resp.status_code == 201

        # Add Photo to candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        data = {
            'photos': [{
                'image_url': 'www.foo.com'
            }, {
                'image_url': 'www.foo.com'
            }]
        }
        create_photo = send_request('post',
                                    CandidateApiUrl.PHOTOS % candidate_id,
                                    access_token_first, data)
        assert create_photo.status_code == 204
        print response_info(create_photo)

        # Retrieve candidate's photo
        get_resp = send_request('get', CandidateApiUrl.PHOTOS % candidate_id,
                                access_token_first)
        print response_info(get_resp)
        assert get_resp.status_code == 200
        assert len(get_resp.json()['candidate_photos']) == 1
Beispiel #20
0
    def test_delete_candidate_education_degrees(self, access_token_first,
                                                talent_pool):
        """
        Test:   Remove all of candidate's degrees from db
        Expect: 204; Candidate should not have any degrees left; Candidate's Education should not be removed
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_educations = get_resp.json()['candidate']['educations']

        # Current number of candidate educations
        count_of_edu_degrees_before_deleting = len(can_educations[0])

        # Remove all of Candidate's degrees
        url = CandidateApiUrl.DEGREES % (candidate_id, can_educations[0]['id'])
        updated_resp = send_request('delete', url, access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == 204
        assert len(can_dict_after_update['educations'][0]['degrees']) == 0
        assert len(can_dict_after_update['educations']
                   [0]) == count_of_edu_degrees_before_deleting
Beispiel #21
0
    def test_delete_candidate_preference(self, access_token_first,
                                         talent_pool):
        """
        Test: Delete candidate's subscription preference
        Expect: 200, should just get an empty dict for subscription_preference
        """
        # Create candidate and candidate's subscription preference
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        candidate_id = create_resp.json()['candidates'][0]['id']
        send_request('post',
                     CandidateApiUrl.CANDIDATE_PREFERENCE % candidate_id,
                     access_token_first, {'frequency_id': 1})

        # Update candidate's subscription preference
        resp = send_request(
            'delete', CandidateApiUrl.CANDIDATE_PREFERENCE % candidate_id,
            access_token_first)
        print response_info(resp)
        assert resp.status_code == 204

        # Retrieve candidate's subscription preference
        resp = send_request(
            'get', CandidateApiUrl.CANDIDATE_PREFERENCE % candidate_id,
            access_token_first)
        print response_info(resp)
        assert resp.status_code == 200
        assert resp.json()['candidate']['subscription_preference'] == {}
Beispiel #22
0
    def test_delete_candidate_military_services(self, access_token_first,
                                                talent_pool):
        """
        Test:   Remove Candidate's military services from db
        Expect: 204, Candidate must not have any military services left
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Delete Candidate's military services
        candidate_id = create_resp.json()['candidates'][0]['id']
        updated_resp = send_request(
            'delete', CandidateApiUrl.MILITARY_SERVICES % candidate_id,
            access_token_first)
        print response_info(updated_resp)

        # Retrieve Candidate after update
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        can_dict_after_update = get_resp.json()['candidate']
        assert updated_resp.status_code == 204
        assert len(can_dict_after_update['military_services']) == 0
Beispiel #23
0
    def test_get_candidate_via_id_and_email(self, access_token_first, user_first, talent_pool):
        """
        Test:   Retrieve candidate via candidate's ID and candidate's Email address
        Expect: 200 in both cases
        """
        # Create candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES, access_token_first, data)
        print response_info(create_resp)
        resp_dict = create_resp.json()

        # Retrieve candidate
        candidate_id = resp_dict['candidates'][0]['id']
        get_resp = send_request('get', CandidateApiUrl.CANDIDATE % candidate_id, access_token_first)

        # Candidate Email
        candidate_email = get_resp.json()['candidate']['emails'][0]['address']

        # Get candidate via Candidate ID
        get_resp = send_request('get', CandidateApiUrl.CANDIDATE % candidate_id, access_token_first)
        resp_dict = get_resp.json()
        print response_info(get_resp)
        assert get_resp.status_code == 200
        assert isinstance(resp_dict, dict)

        # Get candidate via Candidate Email
        get_resp = send_request('get', CandidateApiUrl.CANDIDATE % candidate_email, access_token_first)
        resp_dict = get_resp.json()
        print response_info(get_resp)
        assert get_resp.status_code == 200
        assert isinstance(resp_dict, dict)
Beispiel #24
0
    def test_edit_candidate_experience_bullet(self, access_token_first,
                                              talent_pool):
        """
        Test:   Change Candidate's experience bullet records
        Expect: 200
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        old_experience_dict = get_resp.json(
        )['candidate']['work_experiences'][0]
        old_experience_bullet_dict = old_experience_dict['bullets'][0]

        # Update Candidate's experience bullet
        data = {
            'candidates': [{
                'id':
                candidate_id,
                'work_experiences': [{
                    'id':
                    old_experience_dict['id'],
                    'bullets': [{
                        'id': old_experience_bullet_dict['id'],
                        'description': 'job sucked'
                    }]
                }]
            }]
        }
        send_request('patch', CandidateApiUrl.CANDIDATES, access_token_first,
                     data)

        # Retrieve Candidate
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        new_experience_dict = get_resp.json(
        )['candidate']['work_experiences'][0]
        new_experience_bullet_dict = new_experience_dict['bullets'][0]

        # Retrieve Candidate Edits
        edit_resp = send_request('get',
                                 CandidateApiUrl.CANDIDATE_EDIT % candidate_id,
                                 access_token_first)
        print response_info(edit_resp)

        candidate_edits = edit_resp.json()['candidate']['edits']
        assert edit_resp.status_code == 200
        assert candidate_edits[-1]['old_value'] == old_experience_bullet_dict[
            'description']
        assert candidate_edits[-1]['new_value'] == new_experience_bullet_dict[
            'description']
Beispiel #25
0
    def test_edit_candidate_custom_field(self, access_token_first, talent_pool,
                                         domain_custom_fields):
        """
        Test:   Change Candidate's custom fields
        Expect: 200
        """
        # Create Candidate
        data = generate_single_candidate_data(
            [talent_pool.id], custom_fields=domain_custom_fields)
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(create_resp)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        old_custom_field_dict = get_resp.json(
        )['candidate']['custom_fields'][0]

        # Update Candidate's custom field
        data = {
            'candidates': [{
                'id':
                candidate_id,
                'custom_fields': [{
                    'id': old_custom_field_dict['id'],
                    'value': 'foobar'
                }]
            }]
        }
        send_request('patch', CandidateApiUrl.CANDIDATES, access_token_first,
                     data)

        # Retrieve Candidate custom fields
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        print response_info(get_resp)
        new_custom_field_dict = get_resp.json(
        )['candidate']['custom_fields'][0]

        # Retrieve Candidate Edits
        edit_resp = send_request('get',
                                 CandidateApiUrl.CANDIDATE_EDIT % candidate_id,
                                 access_token_first)
        print response_info(edit_resp)
        candidate_edits = edit_resp.json()['candidate']['edits']

        assert edit_resp.status_code == requests.codes.OK
        assert old_custom_field_dict['value'] in [
            edit['old_value'] for edit in candidate_edits
        ]
        assert new_custom_field_dict['value'] in [
            edit['new_value'] for edit in candidate_edits
        ]
Beispiel #26
0
    def test_edit_candidate_work_preference(self, access_token_first,
                                            talent_pool):
        """
        Test:   Change Candidate's work preference records
        Expect: 200
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(create_resp)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        old_work_pref_dict = get_resp.json()['candidate']['work_preference']

        # Update Candidate's work preference
        data = {
            'candidates': [{
                'id': candidate_id,
                'work_preference': {
                    'id': old_work_pref_dict['id'],
                    'salary': '150000',
                    'hourly_rate': '75'
                }
            }]
        }
        update_resp = send_request('patch', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(update_resp)

        # Retrieve Candidate
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        new_work_pref_dict = get_resp.json()['candidate']['work_preference']

        # Retrieve Candidate Edits
        edit_resp = send_request('get',
                                 CandidateApiUrl.CANDIDATE_EDIT % candidate_id,
                                 access_token_first)
        print response_info(edit_resp)

        candidate_edits = edit_resp.json()['candidate']['edits']
        assert edit_resp.status_code == 200
        old_values = map(get_int_version,
                         [edit['old_value'] for edit in candidate_edits])
        new_values = map(get_int_version,
                         [edit['new_value'] for edit in candidate_edits])
        assert get_int_version(old_work_pref_dict['salary']) in old_values
        assert get_int_version(old_work_pref_dict['hourly_rate']) in old_values
        assert get_int_version(new_work_pref_dict['salary']) in new_values
        assert get_int_version(new_work_pref_dict['hourly_rate']) in new_values
Beispiel #27
0
    def test_edit_candidate_address(self, access_token_first, talent_pool):
        """
        Test:   Edit Candidate's address
        Expect: 200
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        old_address_dict = get_resp.json()['candidate']['addresses'][0]

        # Update Candidate's address
        data = {
            'candidates': [{
                'id':
                candidate_id,
                'addresses': [{
                    'id': old_address_dict['id'],
                    'address_line_1': '255 west santa clara'
                }]
            }]
        }
        send_request('patch', CandidateApiUrl.CANDIDATES, access_token_first,
                     data)

        # Retrieve Candidate addresses
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        new_address_dict = get_resp.json()['candidate']['addresses'][0]

        # Retrieve Candidate Edits
        edit_resp = send_request('get',
                                 CandidateApiUrl.CANDIDATE_EDIT % candidate_id,
                                 access_token_first)
        assert edit_resp.status_code == 200, 'status must be 200. found: {}'.format(
            edit_resp.status_code)
        print response_info(edit_resp)

        candidate_edits = edit_resp.json()['candidate']['edits']
        assert edit_resp.status_code == 200
        assert new_address_dict['address_line_1'] != old_address_dict[
            'address_line_1']
        assert old_address_dict['address_line_1'] in [
            edit['old_value'] for edit in candidate_edits
        ]
        assert new_address_dict['address_line_1'] in [
            edit['new_value'] for edit in candidate_edits
        ]
Beispiel #28
0
    def test_delete_candidate_photos(self, access_token_first, talent_pool):
        # Create candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)
        print response_info(create_resp)
        assert create_resp.status_code == 201

        # Add Photo to candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        data = {
            'photos': [{
                'image_url': fake.url()
            }, {
                'image_url': fake.url()
            }, {
                'image_url': fake.url()
            }]
        }
        create_photo = send_request('post',
                                    CandidateApiUrl.PHOTOS % candidate_id,
                                    access_token_first, data)
        assert create_photo.status_code == 204
        print response_info(create_photo)

        # Retrieve candidate's photos
        get_resp = send_request('get', CandidateApiUrl.PHOTOS % candidate_id,
                                access_token_first)
        print response_info(get_resp)
        candidate_photos = get_resp.json()['candidate_photos']
        assert len(candidate_photos) == 3

        # Delete one of candidate's photos
        photo_id = candidate_photos[0]['id']
        del_resp = send_request(
            'delete', CandidateApiUrl.PHOTO % (candidate_id, photo_id),
            access_token_first)
        print response_info(del_resp)

        # Retrieve candidate's photo
        get_resp = send_request('get', CandidateApiUrl.PHOTOS % candidate_id,
                                access_token_first)
        assert len(get_resp.json()['candidate_photos']) == 2

        # Delete all of candidate's photos
        del_all_resp = send_request('delete',
                                    CandidateApiUrl.PHOTOS % candidate_id,
                                    access_token_first)
        print response_info(del_all_resp)

        # Retrieve candidate's photo
        get_resp = send_request('get', CandidateApiUrl.PHOTOS % candidate_id,
                                access_token_first)
        print response_info(get_resp)
        assert len(get_resp.json()['candidate_photos']) == 0
Beispiel #29
0
    def test_edit_candidate_social_network_edits(self, access_token_first,
                                                 talent_pool):
        """
        Test:   Change Candidate's social network record
        Expect: 200
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        old_sn_dict = get_resp.json()['candidate']['social_networks'][0]

        # Update Candidate's social network
        data = {
            'candidates': [{
                'id':
                candidate_id,
                'social_networks': [{
                    'id': old_sn_dict['id'],
                    'name': 'Facebook',
                    'profile_url': fake.url()
                }]
            }]
        }
        send_request('patch', CandidateApiUrl.CANDIDATES, access_token_first,
                     data)

        # Retrieve Candidate social networks
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        new_sn_dict = get_resp.json()['candidate']['social_networks'][0]

        # Retrieve Candidate Edits
        edit_resp = send_request('get',
                                 CandidateApiUrl.CANDIDATE_EDIT % candidate_id,
                                 access_token_first)
        print response_info(edit_resp)

        candidate_edits = edit_resp.json()['candidate']['edits']
        assert edit_resp.status_code == 200
        assert old_sn_dict['profile_url'] in [
            edit['old_value'] for edit in candidate_edits
        ]
        assert new_sn_dict['profile_url'] in [
            edit['new_value'] for edit in candidate_edits
        ]
Beispiel #30
0
    def test_edit_candidate_military_service(self, access_token_first,
                                             talent_pool):
        """
        Test:   Change Candidate's military service record
        Expect: 200
        """
        # Create Candidate
        data = generate_single_candidate_data([talent_pool.id])
        create_resp = send_request('post', CandidateApiUrl.CANDIDATES,
                                   access_token_first, data)

        # Retrieve Candidate
        candidate_id = create_resp.json()['candidates'][0]['id']
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        old_military_service_dict = get_resp.json(
        )['candidate']['military_services'][0]

        # Update Candidate's military service
        data = {
            'candidates': [{
                'id':
                candidate_id,
                'military_services': [{
                    'id': old_military_service_dict['id'],
                    'branch': 'gettalent'
                }]
            }]
        }
        send_request('patch', CandidateApiUrl.CANDIDATES, access_token_first,
                     data)

        # Retrieve Candidate military services
        get_resp = send_request('get',
                                CandidateApiUrl.CANDIDATE % candidate_id,
                                access_token_first)
        new_military_service_dict = get_resp.json(
        )['candidate']['military_services'][0]

        # Retrieve Candidate Edits
        edit_resp = send_request('get',
                                 CandidateApiUrl.CANDIDATE_EDIT % candidate_id,
                                 access_token_first)
        print response_info(edit_resp)
        candidate_edits = edit_resp.json()['candidate']['edits']
        assert edit_resp.status_code == 200
        assert old_military_service_dict['branch'] in [
            edit['old_value'] for edit in candidate_edits
        ]
        assert new_military_service_dict['branch'] in [
            edit['new_value'] for edit in candidate_edits
        ]