diff --git a/datacatalog/snippets/conftest.py b/datacatalog/snippets/conftest.py index cec3ed8c92be..6060ec87721b 100644 --- a/datacatalog/snippets/conftest.py +++ b/datacatalog/snippets/conftest.py @@ -133,15 +133,18 @@ def policy_tag_manager_client(credentials): @pytest.fixture def random_taxonomy_display_name(policy_tag_manager_client, project_id): now = datetime.datetime.now() - random_display_name = f'example_taxonomy' \ - f'_{now.strftime("%Y%m%d%H%M%S")}' \ - f'_{uuid.uuid4().hex[:8]}' + random_display_name = ( + f"example_taxonomy" + f'_{now.strftime("%Y%m%d%H%M%S")}' + f"_{uuid.uuid4().hex[:8]}" + ) yield random_display_name parent = datacatalog_v1.PolicyTagManagerClient.common_location_path( - project_id, 'us' + project_id, "us" ) taxonomies = policy_tag_manager_client.list_taxonomies(parent=parent) taxonomy = next( - (t for t in taxonomies if t.display_name == random_display_name), None) + (t for t in taxonomies if t.display_name == random_display_name), None + ) if taxonomy: policy_tag_manager_client.delete_taxonomy(name=taxonomy.name) diff --git a/datacatalog/snippets/data_catalog_ptm_create_taxonomy.py b/datacatalog/snippets/data_catalog_ptm_create_taxonomy.py index f6b49ba1c714..5a9d8be1a35b 100644 --- a/datacatalog/snippets/data_catalog_ptm_create_taxonomy.py +++ b/datacatalog/snippets/data_catalog_ptm_create_taxonomy.py @@ -20,11 +20,9 @@ def create_taxonomy( # TODO(developer): Set project_id to the ID of the project the # taxonomy will belong to. project_id: str = "your-project-id", - # TODO(developer): Specify the geographic location where the # taxonomy should reside. location_id: str = "us", - # TODO(developer): Set the display name of the taxonomy. display_name: str = "example-taxonomy", ): @@ -41,10 +39,11 @@ def create_taxonomy( # TODO(developer): Construct a full Taxonomy object to send to the API. taxonomy = datacatalog_v1.Taxonomy() taxonomy.display_name = display_name - taxonomy.description = 'This Taxonomy represents ...' + taxonomy.description = "This Taxonomy represents ..." # Send the taxonomy to the API for creation. taxonomy = client.create_taxonomy(parent=parent, taxonomy=taxonomy) - print(f'Created taxonomy {taxonomy.name}') + print(f"Created taxonomy {taxonomy.name}") + # [END data_catalog_ptm_create_taxonomy] diff --git a/datacatalog/snippets/data_catalog_ptm_create_taxonomy_test.py b/datacatalog/snippets/data_catalog_ptm_create_taxonomy_test.py index 63a913c38e2f..d45cddf074a0 100644 --- a/datacatalog/snippets/data_catalog_ptm_create_taxonomy_test.py +++ b/datacatalog/snippets/data_catalog_ptm_create_taxonomy_test.py @@ -16,14 +16,12 @@ import data_catalog_ptm_create_taxonomy -def test_create_taxonomy(capsys, - project_id: str, - random_taxonomy_display_name: str): +def test_create_taxonomy(capsys, project_id: str, random_taxonomy_display_name: str): data_catalog_ptm_create_taxonomy.create_taxonomy( - project_id=project_id, location_id="us", display_name=random_taxonomy_display_name) - out, _ = capsys.readouterr() - assert ( - f'Created taxonomy projects/{project_id}/locations/us/taxonomies/' - in out + project_id=project_id, + location_id="us", + display_name=random_taxonomy_display_name, ) + out, _ = capsys.readouterr() + assert f"Created taxonomy projects/{project_id}/locations/us/taxonomies/" in out