def test_update_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
        profile = {}

        response = client.update_profile(profile)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.UpdateProfileRequest(
            profile=profile)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_update_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
        profile = {}

        response = client.update_profile(profile)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = profile_service_pb2.UpdateProfileRequest(
            profile=profile)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #3
0
    def update_profile(
        self,
        profile,
        update_mask=None,
        retry=google.api_core.gapic_v1.method.DEFAULT,
        timeout=google.api_core.gapic_v1.method.DEFAULT,
        metadata=None,
    ):
        """
        Updates the specified profile and returns the updated result.

        Example:
            >>> from google.cloud import talent_v4beta1
            >>>
            >>> client = talent_v4beta1.ProfileServiceClient()
            >>>
            >>> # TODO: Initialize `profile`:
            >>> profile = {}
            >>>
            >>> response = client.update_profile(profile)

        Args:
            profile (Union[dict, ~google.cloud.talent_v4beta1.types.Profile]): Required. Profile to be updated.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.talent_v4beta1.types.Profile`
            update_mask (Union[dict, ~google.cloud.talent_v4beta1.types.FieldMask]): A field mask to specify the profile fields to update.

                A full update is performed if it is unset.

                Valid values are:

                -  external\_id
                -  source
                -  source\_types
                -  uri
                -  is\_hirable
                -  create\_time
                -  update\_time
                -  candidate\_update\_time
                -  resume\_update\_time
                -  resume
                -  person\_names
                -  addresses
                -  email\_addresses
                -  phone\_numbers
                -  personal\_uris
                -  additional\_contact\_info
                -  employment\_records
                -  education\_records
                -  skills
                -  activities
                -  publications
                -  patents
                -  certifications
                -  recruiting\_notes
                -  custom\_attributes
                -  group\_id
                -  external\_system
                -  source\_note
                -  primary\_responsibilities
                -  citizenships
                -  work\_authorizations
                -  employee\_types
                -  language\_code
                -  qualification\_summary
                -  allowed\_contact\_types
                -  preferred\_contact\_types
                -  contact\_availability
                -  language\_fluencies
                -  work\_preference
                -  industry\_experiences
                -  work\_environment\_experiences
                -  work\_availability
                -  security\_clearances
                -  references
                -  assessments
                -  interviews

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.talent_v4beta1.types.FieldMask`
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will
                be retried using a default configuration.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.cloud.talent_v4beta1.types.Profile` instance.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.
        """
        # Wrap the transport method to add retry and timeout logic.
        if "update_profile" not in self._inner_api_calls:
            self._inner_api_calls[
                "update_profile"
            ] = google.api_core.gapic_v1.method.wrap_method(
                self.transport.update_profile,
                default_retry=self._method_configs["UpdateProfile"].retry,
                default_timeout=self._method_configs["UpdateProfile"].timeout,
                client_info=self._client_info,
            )

        request = profile_service_pb2.UpdateProfileRequest(
            profile=profile, update_mask=update_mask
        )
        if metadata is None:
            metadata = []
        metadata = list(metadata)
        try:
            routing_header = [("profile.name", profile.name)]
        except AttributeError:
            pass
        else:
            routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
                routing_header
            )
            metadata.append(routing_metadata)

        return self._inner_api_calls["update_profile"](
            request, retry=retry, timeout=timeout, metadata=metadata
        )
Beispiel #4
0
    def update_profile(
        self,
        profile,
        update_mask=None,
        retry=google.api_core.gapic_v1.method.DEFAULT,
        timeout=google.api_core.gapic_v1.method.DEFAULT,
        metadata=None,
    ):
        """
        Updates the specified profile and returns the updated result.

        Example:
            >>> from google.cloud import talent_v4beta1
            >>>
            >>> client = talent_v4beta1.ProfileServiceClient()
            >>>
            >>> # TODO: Initialize `profile`:
            >>> profile = {}
            >>>
            >>> response = client.update_profile(profile)

        Args:
            profile (Union[dict, ~google.cloud.talent_v4beta1.types.Profile]): Required.

                Profile to be updated.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.talent_v4beta1.types.Profile`
            update_mask (Union[dict, ~google.cloud.talent_v4beta1.types.FieldMask]): Optional.

                A field mask to specify the profile fields to update.

                A full update is performed if it is unset.

                Valid values are:

                -  externalId
                -  source
                -  uri
                -  isHirable
                -  createTime
                -  updateTime
                -  resumeHrxml
                -  personNames
                -  addresses
                -  emailAddresses
                -  phoneNumbers
                -  personalUris
                -  additionalContactInfo
                -  employmentRecords
                -  educationRecords
                -  skills
                -  projects
                -  publications
                -  patents
                -  certifications
                -  jobApplications
                -  recruitingNotes
                -  customAttributes

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.talent_v4beta1.types.FieldMask`
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will not
                be retried.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.cloud.talent_v4beta1.types.Profile` instance.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.
        """
        # Wrap the transport method to add retry and timeout logic.
        if "update_profile" not in self._inner_api_calls:
            self._inner_api_calls[
                "update_profile"
            ] = google.api_core.gapic_v1.method.wrap_method(
                self.transport.update_profile,
                default_retry=self._method_configs["UpdateProfile"].retry,
                default_timeout=self._method_configs["UpdateProfile"].timeout,
                client_info=self._client_info,
            )

        request = profile_service_pb2.UpdateProfileRequest(
            profile=profile, update_mask=update_mask
        )
        return self._inner_api_calls["update_profile"](
            request, retry=retry, timeout=timeout, metadata=metadata
        )
Beispiel #5
0
    def update_profile(
        self,
        profile,
        update_mask=None,
        retry=google.api_core.gapic_v1.method.DEFAULT,
        timeout=google.api_core.gapic_v1.method.DEFAULT,
        metadata=None,
    ):
        """
        Updates the specified profile and returns the updated result.

        Example:
            >>> from google.cloud import talent_v4beta1
            >>>
            >>> client = talent_v4beta1.ProfileServiceClient()
            >>>
            >>> # TODO: Initialize `profile`:
            >>> profile = {}
            >>>
            >>> response = client.update_profile(profile)

        Args:
            profile (Union[dict, ~google.cloud.talent_v4beta1.types.Profile]): Required. Profile to be updated.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.talent_v4beta1.types.Profile`
            update_mask (Union[dict, ~google.cloud.talent_v4beta1.types.FieldMask]): A field mask to specify the profile fields to update.

                A full update is performed if it is unset.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.talent_v4beta1.types.FieldMask`
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will
                be retried using a default configuration.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.cloud.talent_v4beta1.types.Profile` instance.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.
        """
        # Wrap the transport method to add retry and timeout logic.
        if "update_profile" not in self._inner_api_calls:
            self._inner_api_calls[
                "update_profile"] = google.api_core.gapic_v1.method.wrap_method(
                    self.transport.update_profile,
                    default_retry=self._method_configs["UpdateProfile"].retry,
                    default_timeout=self._method_configs["UpdateProfile"].
                    timeout,
                    client_info=self._client_info,
                )

        request = profile_service_pb2.UpdateProfileRequest(
            profile=profile, update_mask=update_mask)
        if metadata is None:
            metadata = []
        metadata = list(metadata)
        try:
            routing_header = [("profile.name", profile.name)]
        except AttributeError:
            pass
        else:
            routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
                routing_header)
            metadata.append(routing_metadata)

        return self._inner_api_calls["update_profile"](request,
                                                       retry=retry,
                                                       timeout=timeout,
                                                       metadata=metadata)