Beispiel #1
0
    def test_list_profiles(self):
        # Setup Expected Response
        next_page_token = ""
        profiles_element = {}
        profiles = [profiles_element]
        expected_response = {
            "next_page_token": next_page_token,
            "profiles": profiles
        }
        expected_response = profile_service_pb2.ListProfilesResponse(
            **expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        parent = client.tenant_path("[PROJECT]", "[TENANT]")

        paged_list_response = client.list_profiles(parent)
        resources = list(paged_list_response)
        assert len(resources) == 1

        assert expected_response.profiles[0] == resources[0]

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.ListProfilesRequest(
            parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #2
0
    def test_list_profiles_exception(self):
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup request
        parent = client.tenant_path("[PROJECT]", "[TENANT]")

        paged_list_response = client.list_profiles(parent)
        with pytest.raises(CustomException):
            list(paged_list_response)
Beispiel #3
0
    def test_delete_profile_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup request
        name = client.profile_path("[PROJECT]", "[TENANT]", "[PROFILE]")

        with pytest.raises(CustomException):
            client.delete_profile(name)
Beispiel #4
0
    def test_update_profile_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup request
        profile = {}

        with pytest.raises(CustomException):
            client.update_profile(profile)
    def test_create_profile_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup request
        parent = client.tenant_path('[PROJECT]', '[TENANT]')
        profile = {}

        with pytest.raises(CustomException):
            client.create_profile(parent, profile)
    def test_search_profiles_exception(self):
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup request
        parent = client.company_path('[PROJECT]', '[COMPANY]')
        request_metadata = {}

        paged_list_response = client.search_profiles(parent, request_metadata)
        with pytest.raises(CustomException):
            list(paged_list_response)
Beispiel #7
0
    def test_delete_profile(self):
        channel = ChannelStub()
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        name = client.profile_path("[PROJECT]", "[TENANT]", "[PROFILE]")

        client.delete_profile(name)

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.DeleteProfileRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_profile(self):
        # Setup Expected Response
        name = "name3373707"
        external_id = "externalId-1153075697"
        source = "source-896505829"
        uri = "uri116076"
        group_id = "groupId506361563"
        resume_hrxml = "resumeHrxml1834730555"
        processed = True
        keyword_snippet = "keywordSnippet1325317319"
        expected_response = {
            "name": name,
            "external_id": external_id,
            "source": source,
            "uri": uri,
            "group_id": group_id,
            "resume_hrxml": resume_hrxml,
            "processed": processed,
            "keyword_snippet": keyword_snippet,
        }
        expected_response = profile_pb2.Profile(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        parent = client.tenant_path("[PROJECT]", "[TENANT]")
        profile = {}

        response = client.create_profile(parent, profile)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.CreateProfileRequest(
            parent=parent, profile=profile)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_profile(self):
        # Setup Expected Response
        name = 'name3373707'
        external_id = 'externalId-1153075697'
        source = 'source-896505829'
        uri = 'uri116076'
        group_id = 'groupId506361563'
        resume_hrxml = 'resumeHrxml1834730555'
        processed = True
        keyword_snippet = 'keywordSnippet1325317319'
        expected_response = {
            'name': name,
            'external_id': external_id,
            'source': source,
            'uri': uri,
            'group_id': group_id,
            'resume_hrxml': resume_hrxml,
            'processed': processed,
            'keyword_snippet': keyword_snippet
        }
        expected_response = profile_pb2.Profile(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        parent = client.company_path('[PROJECT]', '[COMPANY]')
        profile = {}

        response = client.create_profile(parent, profile)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.CreateProfileRequest(
            parent=parent, profile=profile)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #10
0
    def test_search_profiles(self):
        # Setup Expected Response
        estimated_total_size = 1882144769
        next_page_token = ""
        result_set_id = "resultSetId-770306950"
        summarized_profiles_element = {}
        summarized_profiles = [summarized_profiles_element]
        expected_response = {
            "estimated_total_size": estimated_total_size,
            "next_page_token": next_page_token,
            "result_set_id": result_set_id,
            "summarized_profiles": summarized_profiles,
        }
        expected_response = profile_service_pb2.SearchProfilesResponse(
            **expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        parent = client.tenant_path("[PROJECT]", "[TENANT]")
        request_metadata = {}

        paged_list_response = client.search_profiles(parent, request_metadata)
        resources = list(paged_list_response)
        assert len(resources) == 1

        assert expected_response.summarized_profiles[0] == resources[0]

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.SearchProfilesRequest(
            parent=parent, request_metadata=request_metadata)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #11
0
    def test_get_profile(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        external_id = "externalId-1153075697"
        source = "source-896505829"
        uri = "uri116076"
        group_id = "groupId506361563"
        processed = True
        keyword_snippet = "keywordSnippet1325317319"
        expected_response = {
            "name": name_2,
            "external_id": external_id,
            "source": source,
            "uri": uri,
            "group_id": group_id,
            "processed": processed,
            "keyword_snippet": keyword_snippet,
        }
        expected_response = profile_pb2.Profile(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        name = client.profile_path("[PROJECT]", "[TENANT]", "[PROFILE]")

        response = client.get_profile(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.GetProfileRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_profile(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        external_id = 'externalId-1153075697'
        source = 'source-896505829'
        uri = 'uri116076'
        group_id = 'groupId506361563'
        processed = True
        keyword_snippet = 'keywordSnippet1325317319'
        expected_response = {
            'name': name_2,
            'external_id': external_id,
            'source': source,
            'uri': uri,
            'group_id': group_id,
            'processed': processed,
            'keyword_snippet': keyword_snippet
        }
        expected_response = profile_pb2.Profile(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        name = client.profile_path('[PROJECT]', '[TENANT]', '[PROFILE]')

        response = client.get_profile(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.GetProfileRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_search_profiles(self):
        # Setup Expected Response
        estimated_total_size = 1882144769
        next_page_token = ''
        summarized_profiles_element = {}
        summarized_profiles = [summarized_profiles_element]
        expected_response = {
            'estimated_total_size': estimated_total_size,
            'next_page_token': next_page_token,
            'summarized_profiles': summarized_profiles
        }
        expected_response = profile_service_pb2.SearchProfilesResponse(
            **expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = talent_v4beta1.ProfileServiceClient()

        # Setup Request
        parent = client.tenant_path('[PROJECT]', '[TENANT]')
        request_metadata = {}

        paged_list_response = client.search_profiles(parent, request_metadata)
        resources = list(paged_list_response)
        assert len(resources) == 1

        assert expected_response.summarized_profiles[0] == resources[0]

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.SearchProfilesRequest(
            parent=parent, request_metadata=request_metadata)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request