Skip to content

Commit 59ff57f

Browse files
steffnaybusunkim96
andauthored
docs(samples): add samples from docs & reorganize all samples for testing (#78)
* chore: re-organize samples to ensure they are all tested * chore: sprinkle in requirements files * fix: fix all the region tags * chore: blacken * test(samples): add tests for generated samples * test: more fixes * test: fix tests * test: fix conftest files * test: fix v1beta1 tests * docs(samples): adds samples from cloud.google.com documentation and tests * docs(samples): remove old quickstart * docs(samples): adds samples from docs * docs(samples): updates quickstart * update v1beta1 samples to pass tests * docs(samples): update * docs(samples): update * update search_assets & test * update * docs(samples): replace deleted region tags * docs(samples): replace deleted region tags * docs(samples): add region tag * docs(samples): update region tags * docs(samples): update samples * docs(samples): add link to all member values * docs(samples): unpin google-cloud-datacatalog, add quickstart link * chore: pinned google-cloud-datacatalog and updated pytest Co-authored-by: Bu Sun Kim <busunkim@google.com>
1 parent c24681c commit 59ff57f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1595
-591
lines changed

datacatalog/__init__.py

Whitespace-only changes.

datacatalog/quickstart/__init__.py

Whitespace-only changes.

datacatalog/quickstart/conftest.py

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright 2019 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+
# https://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+
16+
import datetime
17+
import uuid
18+
19+
import google.auth
20+
from google.cloud import bigquery
21+
from google.cloud import datacatalog_v1
22+
23+
import pytest
24+
25+
26+
def temp_suffix():
27+
now = datetime.datetime.now()
28+
return "{}_{}".format(
29+
now.strftime("%Y%m%d%H%M%S"), uuid.uuid4().hex[:8]
30+
)
31+
32+
33+
@pytest.fixture(scope="session")
34+
def client(credentials):
35+
return datacatalog_v1.DataCatalogClient(credentials=credentials)
36+
37+
38+
@pytest.fixture(scope="session")
39+
def bigquery_client(credentials, project_id):
40+
return bigquery.Client(project=project_id, credentials=credentials)
41+
42+
43+
@pytest.fixture(scope="session")
44+
def default_credentials():
45+
return google.auth.default(scopes=["https://www.googleapis.com/auth/cloud-platform"])
46+
47+
48+
@pytest.fixture(scope="session")
49+
def credentials(default_credentials):
50+
return default_credentials[0]
51+
52+
53+
@pytest.fixture(scope="session")
54+
def project_id(default_credentials):
55+
return default_credentials[1]
56+
57+
58+
@pytest.fixture
59+
def dataset_id(bigquery_client):
60+
dataset_id = f"python_data_catalog_sample_{temp_suffix()}"
61+
dataset = bigquery_client.create_dataset(dataset_id)
62+
yield dataset.dataset_id
63+
bigquery_client.delete_dataset(dataset, delete_contents=True, not_found_ok=True)
64+
65+
66+
@pytest.fixture
67+
def table_id(bigquery_client, project_id, dataset_id):
68+
table_id = f"python_data_catalog_sample_{temp_suffix()}"
69+
table = bigquery.Table("{}.{}.{}".format(project_id, dataset_id, table_id))
70+
table = bigquery_client.create_table(table)
71+
yield table.table_id
72+
bigquery_client.delete_table(table, not_found_ok=True)
73+
74+
75+
@pytest.fixture
76+
def random_tag_template_id():
77+
random_tag_template_id = f"python_sample_{temp_suffix()}"
78+
yield random_tag_template_id

datacatalog/quickstart/create_fileset_entry_quickstart.py

-112
This file was deleted.

0 commit comments

Comments
 (0)