diff --git a/automl/tests/system/gapic/v1beta1/test_system_tables_client_v1.py b/automl/tests/system/gapic/v1beta1/test_system_tables_client_v1.py index 01c49541dc70..27f2e884fb79 100644 --- a/automl/tests/system/gapic/v1beta1/test_system_tables_client_v1.py +++ b/automl/tests/system/gapic/v1beta1/test_system_tables_client_v1.py @@ -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( @@ -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) @@ -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) @@ -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") @@ -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") @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)