Skip to content

Commit 28ba240

Browse files
plamutbusunkim96
authored andcommitted
chore: transition the library to microgenerator (#56)
* chore: remove old GAPIC code * Regenerate the library with microgenerator * Fix docs toctree includes * Update Python version compatibility in README * Adjust samples * Fix datatransfer shim unit test * Reduce required coverage threshold The generated code tests do not cover all code paths after all... * Simplify TransferConfig instantiation in sample * Add UPGRADING guide * Update UPGRADING.md (method name) Co-authored-by: Bu Sun Kim <[email protected]> Co-authored-by: Bu Sun Kim <[email protected]>
1 parent 485189f commit 28ba240

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

bigquery-datatransfer/snippets/quickstart.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
# limitations under the License.
1616

1717

18-
def run_quickstart():
18+
def run_quickstart(project="my-project"):
1919
# [START bigquerydatatransfer_quickstart]
20-
from google.cloud import bigquery_datatransfer
20+
from google.cloud.bigquery import datatransfer
2121

22-
client = bigquery_datatransfer.DataTransferServiceClient()
22+
client = datatransfer.DataTransferServiceClient()
2323

24-
project = 'my-project' # TODO: Update to your project ID.
24+
# TODO: Update to your project ID.
25+
# project = "my-project"
2526

2627
# Get the full path to your project.
27-
parent = client.project_path(project)
28+
parent = f"projects/{project}"
2829

2930
print('Supported Data Sources:')
3031

3132
# Iterate over all possible data sources.
32-
for data_source in client.list_data_sources(parent):
33+
for data_source in client.list_data_sources(parent=parent):
3334
print('{}:'.format(data_source.display_name))
3435
print('\tID: {}'.format(data_source.data_source_id))
3536
print('\tFull path: {}'.format(data_source.name))

bigquery-datatransfer/snippets/quickstart_test.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import os
1616

17-
import mock
1817
import pytest
1918

2019
import quickstart
@@ -24,18 +23,13 @@
2423

2524

2625
@pytest.fixture
27-
def mock_project_path():
26+
def mock_project_id():
2827
"""Mock out project and replace with project from environment."""
29-
project_patch = mock.patch(
30-
'google.cloud.bigquery_datatransfer.DataTransferServiceClient.'
31-
'project_path')
3228

33-
with project_patch as project_mock:
34-
project_mock.return_value = 'projects/{}'.format(PROJECT)
35-
yield project_mock
29+
return PROJECT
3630

3731

38-
def test_quickstart(capsys, mock_project_path):
39-
quickstart.run_quickstart()
32+
def test_quickstart(capsys, mock_project_id):
33+
quickstart.run_quickstart(mock_project_id)
4034
out, _ = capsys.readouterr()
4135
assert 'Supported Data Sources:' in out

0 commit comments

Comments
 (0)