From ff0d2dca8774582ec3ac760a78e8bac33366919c Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Wed, 11 Nov 2020 16:23:03 -0800 Subject: [PATCH] testing(sample): fix broken tests (#108) * testing(sample): fix broken tests fixes #104 fixes #105 * explicitly specify the project id on bucket creation longer timeout --- .../snippets/quickstart_batchgetassetshistory_test.py | 6 +++--- .../samples/snippets/quickstart_searchallresources_test.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/google-cloud-asset/samples/snippets/quickstart_batchgetassetshistory_test.py b/packages/google-cloud-asset/samples/snippets/quickstart_batchgetassetshistory_test.py index fd7622c19461..1bb483ebead7 100644 --- a/packages/google-cloud-asset/samples/snippets/quickstart_batchgetassetshistory_test.py +++ b/packages/google-cloud-asset/samples/snippets/quickstart_batchgetassetshistory_test.py @@ -30,12 +30,12 @@ @pytest.fixture(scope="module") def storage_client(): - yield storage.Client() + yield storage.Client(project=PROJECT) @pytest.fixture(scope="module") def asset_bucket(storage_client): - bucket = storage_client.create_bucket(BUCKET) + bucket = storage_client.create_bucket(BUCKET, project=PROJECT) yield BUCKET @@ -52,7 +52,7 @@ def test_batch_get_assets_history(asset_bucket, capsys): bucket_asset_name, ] - @backoff.on_exception(backoff.expo, (AssertionError, InvalidArgument), max_time=30) + @backoff.on_exception(backoff.expo, (AssertionError, InvalidArgument), max_time=60) def eventually_consistent_test(): quickstart_batchgetassetshistory.batch_get_assets_history(PROJECT, asset_names) out, _ = capsys.readouterr() diff --git a/packages/google-cloud-asset/samples/snippets/quickstart_searchallresources_test.py b/packages/google-cloud-asset/samples/snippets/quickstart_searchallresources_test.py index f27eeb3b39c1..da019752270d 100644 --- a/packages/google-cloud-asset/samples/snippets/quickstart_searchallresources_test.py +++ b/packages/google-cloud-asset/samples/snippets/quickstart_searchallresources_test.py @@ -53,7 +53,7 @@ def test_search_all_resources(asset_dataset, capsys): # Dataset creation takes some time to propagate, so the dataset is not # immediately searchable. Need some time before the snippet will pass. - @backoff.on_exception(backoff.expo, (AssertionError), max_time=120) + @backoff.on_exception(backoff.expo, (AssertionError), max_time=240) def eventually_consistent_test(): quickstart_searchallresources.search_all_resources(scope, query=query) out, _ = capsys.readouterr()