forked from googleapis/python-vision
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: vision product search tests to call setup and teardown and use u…
…uid [(#2830)](GoogleCloudPlatform/python-docs-samples#2830)
- Loading branch information
Showing
8 changed files
with
145 additions
and
119 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
samples/snippets/product_search/create_product_set_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import uuid | ||
|
||
import pytest | ||
|
||
from product_set_management import ( | ||
create_product_set, delete_product_set, list_product_sets) | ||
|
||
|
||
PROJECT_ID = os.getenv('GCLOUD_PROJECT') | ||
LOCATION = 'us-west1' | ||
|
||
PRODUCT_SET_DISPLAY_NAME = 'fake_product_set_display_name_for_testing' | ||
PRODUCT_SET_ID = 'test_{}'.format(uuid.uuid4()) | ||
|
||
|
||
@pytest.fixture(scope="function", autouse=True) | ||
def teardown(): | ||
yield | ||
|
||
# tear down | ||
delete_product_set(PROJECT_ID, LOCATION, PRODUCT_SET_ID) | ||
|
||
|
||
def test_create_product_set(capsys): | ||
create_product_set( | ||
PROJECT_ID, LOCATION, PRODUCT_SET_ID, | ||
PRODUCT_SET_DISPLAY_NAME) | ||
list_product_sets(PROJECT_ID, LOCATION) | ||
out, _ = capsys.readouterr() | ||
assert PRODUCT_SET_ID in out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import uuid | ||
|
||
import pytest | ||
|
||
from product_management import create_product, delete_product, list_products | ||
|
||
|
||
PROJECT_ID = os.getenv('GCLOUD_PROJECT') | ||
LOCATION = 'us-west1' | ||
|
||
PRODUCT_DISPLAY_NAME = 'fake_product_display_name_for_testing' | ||
PRODUCT_CATEGORY = 'homegoods' | ||
PRODUCT_ID = 'test_{}'.format(uuid.uuid4()) | ||
|
||
|
||
@pytest.fixture(scope="function", autouse=True) | ||
def teardown(): | ||
yield | ||
|
||
# tear down | ||
delete_product(PROJECT_ID, LOCATION, PRODUCT_ID) | ||
|
||
|
||
def test_create_product(capsys): | ||
create_product( | ||
PROJECT_ID, LOCATION, PRODUCT_ID, | ||
PRODUCT_DISPLAY_NAME, PRODUCT_CATEGORY) | ||
list_products(PROJECT_ID, LOCATION) | ||
out, _ = capsys.readouterr() | ||
assert PRODUCT_ID in out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.