From 9345891fbe734ade9af21b8ea7ab5ea3d73becc2 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 --- samples/snippets/quickstart_batchgetassetshistory_test.py | 6 +++--- samples/snippets/quickstart_searchallresources_test.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/snippets/quickstart_batchgetassetshistory_test.py b/samples/snippets/quickstart_batchgetassetshistory_test.py index fd7622c1..1bb483eb 100644 --- a/samples/snippets/quickstart_batchgetassetshistory_test.py +++ b/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/samples/snippets/quickstart_searchallresources_test.py b/samples/snippets/quickstart_searchallresources_test.py index f27eeb3b..da019752 100644 --- a/samples/snippets/quickstart_searchallresources_test.py +++ b/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()