Skip to content

Commit 759db93

Browse files
Takashi Matsuoleahecole
andauthored
[jobs] testing: use multiple projects (GoogleCloudPlatform#3973)
* [jobs] testing: use multiple projects fixes GoogleCloudPlatform#3969 * Always wait 60 seconds before retrying Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
1 parent 6b5f855 commit 759db93

4 files changed

Lines changed: 236 additions & 11 deletions

File tree

jobs/v3/api_client/README.rst

Lines changed: 182 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ Google Cloud Talent Solution API Python Samples
44
===============================================================================
55

66
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
7-
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/cjd_sample/README.rst
7+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/README.rst
88

99

10-
This directory contains samples for Google Cloud Talent Solution API.
11-
The `Google Talent Solution API` is part of Google for Jobs - a Google-wide commitment to help people find jobs more easily. Talent Solution provides plug and play access to Google’s search and machine learning capabilities, enabling the entire recruiting ecosystem - company career sites, job boards, applicant tracking systems, and staffing agencies to improve job site engagement and candidate conversion.
10+
This directory contains samples for Google Cloud Talent Solution API. `Cloud Talent Solution` is a service that brings machine learning to your job
11+
search experience, returning high quality results to job seekers far beyond
12+
the limitations of typical keyword-based methods. Once integrated with your
13+
job content, Cloud Talent Solution automatically detects and infers various
14+
kinds of data, such as related titles, seniority, and industry.
15+
1216

1317

1418

1519
.. _Google Cloud Talent Solution API: https://cloud.google.com/talent-solution/job-search/docs/
1620

21+
To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/jobs.googleapis.com
22+
23+
To run the sample, you need to have `Talent Solution Job Editor` role.
24+
25+
26+
Visit [Data logging page](https://console.cloud.google.com/talent-solution/data-permission-onboard) and enable the Data logging on your cloud project and connect at least one service account.
27+
28+
1729
Setup
1830
-------------------------------------------------------------------------------
1931

@@ -61,11 +73,29 @@ Install Dependencies
6173
Samples
6274
-------------------------------------------------------------------------------
6375

64-
Quickstart
76+
AutoCompleteSample
6577
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6678

6779
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
68-
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/cjd_sample/base_company_sample.py,jobs/cjd_sample/README.rst
80+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/auto_complete_sample.py,jobs/v2/api_client/README.rst
81+
82+
83+
84+
85+
To run this sample:
86+
87+
.. code-block:: bash
88+
89+
$ python auto_complete_sample.py
90+
91+
92+
BaseCompanySample
93+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94+
95+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
96+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/base_company_sample.py,jobs/v2/api_client/README.rst
97+
98+
6999

70100

71101
To run this sample:
@@ -75,4 +105,150 @@ To run this sample:
75105
$ python base_company_sample.py
76106
77107
78-
.. _Google Cloud SDK: https://cloud.google.com/sdk/
108+
BaseJobSample
109+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110+
111+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
112+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/base_job_sample.py,jobs/v2/api_client/README.rst
113+
114+
115+
116+
117+
To run this sample:
118+
119+
.. code-block:: bash
120+
121+
$ python base_job_sample.py
122+
123+
124+
BatchOperationSample
125+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
126+
127+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
128+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/batch_operation_sample.py,jobs/v2/api_client/README.rst
129+
130+
131+
132+
133+
To run this sample:
134+
135+
.. code-block:: bash
136+
137+
$ python batch_operation_sample.py
138+
139+
140+
CommuteSearchSample
141+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
142+
143+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
144+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/commute_search_sample.py,jobs/v2/api_client/README.rst
145+
146+
147+
148+
149+
To run this sample:
150+
151+
.. code-block:: bash
152+
153+
$ python commute_search_sample.py
154+
155+
156+
CustomAttributeSample
157+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158+
159+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
160+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/custom_attribute_sample.py,jobs/v2/api_client/README.rst
161+
162+
163+
164+
165+
To run this sample:
166+
167+
.. code-block:: bash
168+
169+
$ python custom_attribute_sample.py
170+
171+
172+
EmailAlertSearchSample
173+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174+
175+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
176+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/email_alert_search_sample.py,jobs/v2/api_client/README.rst
177+
178+
179+
180+
181+
To run this sample:
182+
183+
.. code-block:: bash
184+
185+
$ python email_alert_search_sample.py
186+
187+
188+
FeaturedJobSearchSample
189+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
190+
191+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
192+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/featured_job_search_sample.py,jobs/v2/api_client/README.rst
193+
194+
195+
196+
197+
To run this sample:
198+
199+
.. code-block:: bash
200+
201+
$ python featured_job_search_sample.py
202+
203+
204+
GeneraSearchSample
205+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
206+
207+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
208+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/general_search_sample.py,jobs/v2/api_client/README.rst
209+
210+
211+
212+
213+
To run this sample:
214+
215+
.. code-block:: bash
216+
217+
$ python general_search_sample.py
218+
219+
220+
HistogramSample
221+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
222+
223+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
224+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/histogram_sample.py,jobs/v2/api_client/README.rst
225+
226+
227+
228+
229+
To run this sample:
230+
231+
.. code-block:: bash
232+
233+
$ python histogram_sample.py
234+
235+
236+
LocationSearchSample
237+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
238+
239+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
240+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=jobs/v2/api_client/location_search_sample.py,jobs/v2/api_client/README.rst
241+
242+
243+
244+
245+
To run this sample:
246+
247+
.. code-block:: bash
248+
249+
$ python location_search_sample.py
250+
251+
252+
253+
254+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

jobs/v3/api_client/README.rst.in

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ product:
44
name: Google Cloud Talent Solution API
55
short_name: CTS
66
url: https://cloud.google.com/talent-solution/job-search/docs/
7-
description: >
7+
description: >
88
`Cloud Talent Solution` is a service that brings machine learning to your job
9-
search experience, returning high quality results to job seekers far beyond
10-
the limitations of typical keyword-based methods. Once integrated with your
11-
job content, Cloud Talent Solution automatically detects and infers various
9+
search experience, returning high quality results to job seekers far beyond
10+
the limitations of typical keyword-based methods. Once integrated with your
11+
job content, Cloud Talent Solution automatically detects and infers various
1212
kinds of data, such as related titles, seniority, and industry.
1313

14+
required_api_url: https://console.cloud.google.com/apis/library/jobs.googleapis.com
15+
required_role: Talent Solution Job Editor
16+
other_required_steps: >
17+
Visit [Data logging page](https://console.cloud.google.com/talent-solution/data-permission-onboard) and enable the Data logging on your cloud project and connect at least one service account.
18+
19+
1420
setup:
1521
- auth
1622
- install_deps

jobs/v3/api_client/email_alert_search_sample_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ def company_name():
2626
email_alert_search_sample.tear_down(company_name, job_name)
2727

2828

29+
def retry_delay():
30+
# Always wait 60 seconds
31+
yield 60
32+
33+
2934
def test_email_alert_search_sample(company_name, capsys):
30-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
35+
36+
@backoff.on_exception(retry_delay, AssertionError, max_time=240)
3137
def eventually_consistent_test():
3238
email_alert_search_sample.run_sample(company_name)
3339
out, _ = capsys.readouterr()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Default TEST_CONFIG_OVERRIDE for python repos.
16+
17+
# You can copy this file into your directory, then it will be inported from
18+
# the noxfile.py.
19+
20+
# The source of truth:
21+
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py
22+
23+
TEST_CONFIG_OVERRIDE = {
24+
# You can opt out from the test for specific Python versions.
25+
'ignored_versions': ["2.7"],
26+
27+
# An envvar key for determining the project id to use. Change it
28+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
29+
# build specific Cloud project. You can also use your own string
30+
# to use your own Cloud project.
31+
# 'gcloud_project_env': 'GCLOUD_PROJECT',
32+
'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
33+
34+
# A dictionary you want to inject into your test. Don't put any
35+
# secrets here. These values will override predefined values.
36+
'envs': {},
37+
}

0 commit comments

Comments
 (0)