Skip to content

Commit

Permalink
chore(deps): update dependency google-cloud-storage to v1.28.1 [(#3785)…
Browse files Browse the repository at this point in the history
…](#3785)

* chore(deps): update dependency google-cloud-storage to v1.28.1

* [asset] testing: use uuid instead of time

Co-authored-by: Takashi Matsuo <tmatsuo@google.com>
  • Loading branch information
2 people authored and busunkim96 committed Aug 4, 2020
1 parent c71b19b commit 5a311a2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
25 changes: 15 additions & 10 deletions asset/snippets/snippets/quickstart_batchgetassetshistory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
# limitations under the License.

import os
import time
import uuid

import backoff
from google.api_core.exceptions import InvalidArgument
from google.cloud import storage
import pytest

import quickstart_batchgetassetshistory

PROJECT = os.environ['GCLOUD_PROJECT']
BUCKET = 'assets-{}'.format(int(time.time()))
BUCKET = 'assets-{}'.format(uuid.uuid4().hex)


@pytest.fixture(scope='module')
Expand All @@ -47,12 +49,15 @@ def asset_bucket(storage_client):
def test_batch_get_assets_history(asset_bucket, capsys):
bucket_asset_name = '//storage.googleapis.com/{}'.format(BUCKET)
asset_names = [bucket_asset_name, ]
# There's some delay between bucket creation and when it's reflected in the
# backend.
time.sleep(15)
quickstart_batchgetassetshistory.batch_get_assets_history(
PROJECT, asset_names)
out, _ = capsys.readouterr()

if not out:

@backoff.on_exception(
backoff.expo, (AssertionError, InvalidArgument), max_time=30
)
def eventually_consistent_test():
quickstart_batchgetassetshistory.batch_get_assets_history(
PROJECT, asset_names)
out, _ = capsys.readouterr()

assert bucket_asset_name in out

eventually_consistent_test()
8 changes: 4 additions & 4 deletions asset/snippets/snippets/quickstart_createfeed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import json
import os
import time
import uuid

from google.cloud import pubsub_v1
from google.cloud import resource_manager
Expand All @@ -27,9 +27,9 @@
json_data = open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]).read()
data = json.loads(json_data)
PROJECT = data['project_id']
ASSET_NAME = 'assets-{}'.format(int(time.time()))
FEED_ID = 'feed-{}'.format(int(time.time()))
TOPIC = 'topic-{}'.format(int(time.time()))
ASSET_NAME = 'assets-{}'.format(uuid.uuid4().hex)
FEED_ID = 'feed-{}'.format(uuid.uuid4().hex)
TOPIC = 'topic-{}'.format(uuid.uuid4().hex)


def test_create_feed(capsys):
Expand Down
8 changes: 4 additions & 4 deletions asset/snippets/snippets/quickstart_deletefeed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import os
import time
import uuid

from google.cloud import pubsub_v1
from google.cloud import resource_manager
Expand All @@ -24,9 +24,9 @@
import quickstart_deletefeed

PROJECT = os.environ['GCLOUD_PROJECT']
ASSET_NAME = 'assets-{}'.format(int(time.time()))
FEED_ID = 'feed-{}'.format(int(time.time()))
TOPIC = 'topic-{}'.format(int(time.time()))
ASSET_NAME = 'assets-{}'.format(uuid.uuid4().hex)
FEED_ID = 'feed-{}'.format(uuid.uuid4().hex)
TOPIC = 'topic-{}'.format(uuid.uuid4().hex)


def test_delete_feed(capsys):
Expand Down
4 changes: 2 additions & 2 deletions asset/snippets/snippets/quickstart_exportassets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# limitations under the License.

import os
import time
import uuid

from google.cloud import storage
import pytest

import quickstart_exportassets

PROJECT = os.environ['GCLOUD_PROJECT']
BUCKET = 'assets-{}'.format(int(time.time()))
BUCKET = 'assets-{}'.format(uuid.uuid4().hex)


@pytest.fixture(scope='module')
Expand Down
8 changes: 4 additions & 4 deletions asset/snippets/snippets/quickstart_getfeed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import os
import time
import uuid

from google.cloud import pubsub_v1
from google.cloud import resource_manager
Expand All @@ -25,9 +25,9 @@
import quickstart_getfeed

PROJECT = os.environ['GCLOUD_PROJECT']
ASSET_NAME = 'assets-{}'.format(int(time.time()))
FEED_ID = 'feed-{}'.format(int(time.time()))
TOPIC = 'topic-{}'.format(int(time.time()))
ASSET_NAME = 'assets-{}'.format(uuid.uuid4().hex)
FEED_ID = 'feed-{}'.format(uuid.uuid4().hex)
TOPIC = 'topic-{}'.format(uuid.uuid4().hex)


def test_get_feed(capsys):
Expand Down
10 changes: 5 additions & 5 deletions asset/snippets/snippets/quickstart_updatefeed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import os
import time
import uuid

from google.cloud import pubsub_v1
from google.cloud import resource_manager
Expand All @@ -25,10 +25,10 @@
import quickstart_updatefeed

PROJECT = os.environ['GCLOUD_PROJECT']
ASSET_NAME = 'assets-{}'.format(int(time.time()))
FEED_ID = 'feed-{}'.format(int(time.time()))
TOPIC = 'topic-{}'.format(int(time.time()))
NEW_TOPIC = 'new-topic-{}'.format(int(time.time()))
ASSET_NAME = 'assets-{}'.format(uuid.uuid4().hex)
FEED_ID = 'feed-{}'.format(uuid.uuid4().hex)
TOPIC = 'topic-{}'.format(uuid.uuid4().hex)
NEW_TOPIC = 'new-topic-{}'.format(uuid.uuid4().hex)


def test_update_feed(capsys):
Expand Down
3 changes: 2 additions & 1 deletion asset/snippets/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest==5.3.2
backoff==1.10.0
pytest==5.4.1
2 changes: 1 addition & 1 deletion asset/snippets/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
google-cloud-storage==1.28.0
google-cloud-storage==1.28.1
google-cloud-asset==0.10.0
google-cloud-resource-manager==0.30.1
google-cloud-pubsub==1.4.3

0 comments on commit 5a311a2

Please sign in to comment.