Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
chore: Making the default_values tests be more stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-strzelczyk committed Aug 2, 2021
1 parent 91f43bb commit 9ad2bc9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions samples/snippets/test_sample_default_values.py
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import typing
import uuid
import time

import google.auth
import google.cloud.storage as storage
Expand All @@ -37,13 +38,15 @@ def temp_bucket():
def test_set_usage_export_bucket_default(capsys: typing.Any,
temp_bucket: storage.Bucket) -> None:
set_usage_export_bucket(project_id=PROJECT, bucket_name=temp_bucket.name)
time.sleep(5) # To make sure the settings are properly updated
uel = get_usage_export_bucket(project_id=PROJECT)
assert(uel.bucket_name == temp_bucket.name)
assert(uel.report_name_prefix == 'usage_gce')
out, _ = capsys.readouterr()
assert('default prefix of `usage_gce`.' in out)

disable_usage_export(project_id=PROJECT)
time.sleep(5) # To make sure the settings are properly updated
uel = get_usage_export_bucket(project_id=PROJECT)
assert(uel.bucket_name == '')
assert(uel.report_name_prefix == '')
Expand All @@ -53,13 +56,15 @@ def test_set_usage_export_bucket_custom(capsys: typing.Any,
temp_bucket: storage.Bucket) -> None:
set_usage_export_bucket(project_id=PROJECT, bucket_name=temp_bucket.name,
report_name_prefix=TEST_PREFIX)
time.sleep(5) # To make sure the settings are properly updated
uel = get_usage_export_bucket(project_id=PROJECT)
assert(uel.bucket_name == temp_bucket.name)
assert(uel.report_name_prefix == TEST_PREFIX)
out, _ = capsys.readouterr()
assert('usage_gce' not in out)

disable_usage_export(project_id=PROJECT)
time.sleep(5) # To make sure the settings are properly updated
uel = get_usage_export_bucket(project_id=PROJECT)
assert(uel.bucket_name == '')
assert(uel.report_name_prefix == '')

0 comments on commit 9ad2bc9

Please sign in to comment.