Skip to content

Commit 5a0e6a3

Browse files
Takashi Matsuodandhlee
Takashi Matsuo
authored andcommitted
[jobs] testing: use multiple projects [(#4068)](#4068)
* [jobs] testing: use multiple projects * added README
1 parent fc3c46e commit 5a0e6a3

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

talent/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/jobs.googleapis.com
2+
3+
To run the sample, you need to have the following roles:
4+
5+
* `Talent Solution Job Editor`
6+
* `Talent Solution Profile Editor`

talent/job_search_list_tenants_test.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,30 @@
1313
# limitations under the License.
1414

1515
import os
16+
import uuid
17+
18+
from google.cloud import talent
19+
import pytest
1620

1721
import job_search_list_tenants
1822

1923
PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
2024

2125

22-
def test_list_tenants(capsys):
26+
@pytest.fixture(scope="module")
27+
def test_tenant():
28+
client = talent.TenantServiceClient()
29+
external_id = f'test_tenant_{uuid.uuid4().hex}'
30+
parent = client.project_path(PROJECT_ID)
31+
tenant = {"external_id": external_id}
32+
resp = client.create_tenant(parent, tenant)
33+
34+
yield resp
35+
36+
client.delete_tenant(resp.name)
37+
38+
39+
def test_list_tenants(capsys, test_tenant):
2340
job_search_list_tenants.list_tenants(PROJECT_ID)
2441
out, _ = capsys.readouterr()
2542
assert "Tenant Name:" in out

talent/noxfile_config.py

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': 'GOOGLE_CLOUD_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)