Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(automl): normalize VPCSC configuration in systests #9607

Merged
merged 1 commit into from
Nov 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions automl/tests/system/gapic/v1beta1/test_system_tables_client_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
from google.api_core import exceptions
from google.cloud.automl_v1beta1.gapic import enums

from test_utils.vpcsc_config import vpcsc_config

PROJECT = os.environ["PROJECT_ID"]
REGION = "us-central1"
MAX_WAIT_TIME_SECONDS = 30
MAX_SLEEP_TIME_SECONDS = 5
STATIC_DATASET = "test_dataset_do_not_delete"
STATIC_MODEL = "test_model_do_not_delete"
RUNNING_IN_VPCSC = os.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC", "").lower() == "true"

ID = "{rand}_{time}".format(
rand="".join(
Expand All @@ -58,7 +59,7 @@ def cancel_and_wait(self, op):
sleep_time = min(sleep_time * 2, MAX_SLEEP_TIME_SECONDS)
assert op.cancelled()

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_list_datasets(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -69,7 +70,7 @@ def test_list_datasets(self):
)
)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_list_models(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
model = self.ensure_model_ready(client)
Expand All @@ -86,7 +87,7 @@ def test_create_delete_dataset(self):
)
client.delete_dataset(dataset=dataset)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_import_data(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
display_name = _id("t_import")
Expand All @@ -98,7 +99,7 @@ def test_import_data(self):
self.cancel_and_wait(op)
client.delete_dataset(dataset=dataset)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_import_pandas_dataframe(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
display_name = _id("t_import_pandas")
Expand Down Expand Up @@ -127,7 +128,7 @@ def ensure_dataset_ready(self, client):

return dataset

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_list_column_specs(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -142,21 +143,21 @@ def test_list_column_specs(self):
)
)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_get_column_spec(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
name = [d for d in client.list_column_specs(dataset=dataset)][0].name
assert client.get_column_spec(name).name == name

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_list_table_specs(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
name = [d for d in client.list_table_specs(dataset=dataset)][0].name
assert client.get_table_spec(name).name == name

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_set_column_nullable(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -166,7 +167,7 @@ def test_set_column_nullable(self):
columns = {c.display_name: c for c in client.list_column_specs(dataset=dataset)}
assert columns["POutcome"].data_type.nullable == True

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_set_target_column(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -178,7 +179,7 @@ def test_set_target_column(self):
"/{}".format(metadata.target_column_spec_id)
)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_set_weight_column(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -190,7 +191,7 @@ def test_set_weight_column(self):
"/{}".format(metadata.weight_column_spec_id)
)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_set_weight_and_target_column(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -206,7 +207,7 @@ def test_set_weight_and_target_column(self):
"/{}".format(metadata.target_column_spec_id)
)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_create_delete_model(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
dataset = self.ensure_dataset_ready(client)
Expand All @@ -218,7 +219,7 @@ def test_create_delete_model(self):
self.cancel_and_wait(op)
client.delete_model(model_display_name=display_name)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_list_model_evaluations(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
model = self.ensure_model_online(client)
Expand All @@ -233,14 +234,14 @@ def test_list_model_evaluations(self):
)
)

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_get_model_evaluation(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
model = self.ensure_model_online(client)
name = [m for m in client.list_model_evaluations(model=model)][0].name
assert client.get_model_evaluation(model_evaluation_name=name).name == name

@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
@vpcsc_config.skip_if_inside_vpcsc
def test_online_predict(self):
client = automl_v1beta1.TablesClient(project=PROJECT, region=REGION)
model = self.ensure_model_online(client)
Expand Down