From 66e09af1b0c6188393bf5c5b49c44933ed2f45b9 Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Thu, 19 Dec 2024 14:26:03 +0100 Subject: [PATCH 01/10] feat: resource tags in dataset --- google/cloud/bigquery/dataset.py | 20 ++++++++++++++++++++ tests/unit/test_client.py | 6 ++++++ tests/unit/test_create_dataset.py | 5 +++++ tests/unit/test_dataset.py | 24 ++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py index c49a52faf..b896d4ab6 100644 --- a/google/cloud/bigquery/dataset.py +++ b/google/cloud/bigquery/dataset.py @@ -801,6 +801,26 @@ def labels(self, value): raise ValueError("Pass a dict") self._properties["labels"] = value + @property + def resource_tags(self): + """Dict[str, str]: Resource tags of the dataset. + + This method always returns a dict. To change a dataset's resource tags, + modify the dict, then call + :meth:`google.cloud.bigquery.client.Client.update_dataset`. To delete + a resource tag, set its value to :data:`None` before updating. + + Raises: + ValueError: for invalid value types. + """ + return self._properties.setdefault("resourceTags", {}) + + @resource_tags.setter + def resource_tags(self, value): + if not isinstance(value, dict): + raise ValueError("Pass a dict") + self._properties["resourceTags"] = value + @property def default_encryption_configuration(self): """google.cloud.bigquery.encryption_configuration.EncryptionConfiguration: Custom diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index cd336b73f..14089b031 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -2028,6 +2028,7 @@ def test_update_dataset(self): LABELS = {"priority": "high"} ACCESS = [{"role": "OWNER", "userByEmail": "phred@example.com"}] EXP = 17 + RESOURCE_TAGS = {"123456789012/key": "value"} RESOURCE = { "datasetReference": {"projectId": self.PROJECT, "datasetId": self.DS_ID}, "etag": "etag", @@ -2037,6 +2038,7 @@ def test_update_dataset(self): "defaultTableExpirationMs": EXP, "labels": LABELS, "access": ACCESS, + "resourceTags": RESOURCE_TAGS, } creds = _make_credentials() client = self._make_one(project=self.PROJECT, credentials=creds) @@ -2048,12 +2050,14 @@ def test_update_dataset(self): ds.default_table_expiration_ms = EXP ds.labels = LABELS ds.access_entries = [AccessEntry("OWNER", "userByEmail", "phred@example.com")] + ds.resource_tags = RESOURCE_TAGS fields = [ "description", "friendly_name", "location", "labels", "access_entries", + "resource_tags", ] with mock.patch( @@ -2077,6 +2081,7 @@ def test_update_dataset(self): "location": LOCATION, "labels": LABELS, "access": ACCESS, + "resourceTags": RESOURCE_TAGS, }, path="/" + PATH, timeout=7.5, @@ -2086,6 +2091,7 @@ def test_update_dataset(self): self.assertEqual(ds2.location, ds.location) self.assertEqual(ds2.labels, ds.labels) self.assertEqual(ds2.access_entries, ds.access_entries) + self.assertEqual(ds2.resource_tags, ds.resource_tags) # ETag becomes If-Match header. ds._properties["etag"] = "etag" diff --git a/tests/unit/test_create_dataset.py b/tests/unit/test_create_dataset.py index a2491a812..bd7c6a8f8 100644 --- a/tests/unit/test_create_dataset.py +++ b/tests/unit/test_create_dataset.py @@ -65,6 +65,7 @@ def test_create_dataset_w_attrs(client, PROJECT, DS_ID): "tableId": "northern-hemisphere", } DEFAULT_ROUNDING_MODE = "ROUND_HALF_EVEN" + RESOURCE_TAGS = {"123456789012/foo": "bar"} RESOURCE = { "datasetReference": {"projectId": PROJECT, "datasetId": DS_ID}, "etag": "etag", @@ -76,6 +77,7 @@ def test_create_dataset_w_attrs(client, PROJECT, DS_ID): "labels": LABELS, "access": [{"role": "OWNER", "userByEmail": USER_EMAIL}, {"view": VIEW}], "defaultRoundingMode": DEFAULT_ROUNDING_MODE, + "resourceTags": RESOURCE_TAGS, } conn = client._connection = make_connection(RESOURCE) entries = [ @@ -91,6 +93,7 @@ def test_create_dataset_w_attrs(client, PROJECT, DS_ID): before.default_table_expiration_ms = 3600 before.location = LOCATION before.labels = LABELS + before.resource_tags = RESOURCE_TAGS before.default_rounding_mode = DEFAULT_ROUNDING_MODE after = client.create_dataset(before) assert after.dataset_id == DS_ID @@ -103,6 +106,7 @@ def test_create_dataset_w_attrs(client, PROJECT, DS_ID): assert after.default_table_expiration_ms == 3600 assert after.labels == LABELS assert after.default_rounding_mode == DEFAULT_ROUNDING_MODE + assert after.resource_tags == RESOURCE_TAGS conn.api_request.assert_called_once_with( method="POST", @@ -119,6 +123,7 @@ def test_create_dataset_w_attrs(client, PROJECT, DS_ID): {"view": VIEW, "role": None}, ], "labels": LABELS, + "resourceTags": RESOURCE_TAGS, }, timeout=DEFAULT_TIMEOUT, ) diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index c0164bc73..590ff0196 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -894,6 +894,27 @@ def test_location_setter(self): dataset.location = "LOCATION" self.assertEqual(dataset.location, "LOCATION") + def test_resource_tags_update_in_place(self): + dataset = self._make_one(self.DS_REF) + del dataset._properties["resourceTags"] # don't start w/ existing dict + tags = dataset.resource_tags + tags["123456789012/foo"] = "bar" # update in place + self.assertEqual(dataset.resource_tags, {"123456789012/foo": "bar"}) + + def test_resource_tags_setter(self): + dataset = self._make_one(self.DS_REF) + dataset.resource_tags = {"123456789012/foo": "bar"} + self.assertEqual(dataset.labels, {"123456789012/foo": "bar"}) + + def test_resource_tags_setter_bad_value(self): + dataset = self._make_one(self.DS_REF) + with self.assertRaises(ValueError): + dataset.resource_tags = None + + def test_resource_tags_getter_missing_value(self): + dataset = self._make_one(self.DS_REF) + self.assertEqual(dataset.resource_tags, {}) + def test_labels_update_in_place(self): dataset = self._make_one(self.DS_REF) del dataset._properties["labels"] # don't start w/ existing dict @@ -1065,6 +1086,7 @@ def test_ctor(self): "datasetReference": {"projectId": project, "datasetId": dataset_id}, "friendlyName": "Data of the Test", "labels": {"some-stuff": "this-is-a-label"}, + "resourceTags": {"123456789012/foo": "bar"}, } dataset = self._make_one(resource) @@ -1075,6 +1097,7 @@ def test_ctor(self): self.assertEqual(dataset.reference.dataset_id, dataset_id) self.assertEqual(dataset.friendly_name, "Data of the Test") self.assertEqual(dataset.labels["some-stuff"], "this-is-a-label") + self.assertEqual(dataset.resource_tags["123456789012/foo"], "bar") def test_ctor_missing_properties(self): resource = { @@ -1086,6 +1109,7 @@ def test_ctor_missing_properties(self): self.assertIsNone(dataset.full_dataset_id) self.assertIsNone(dataset.friendly_name) self.assertEqual(dataset.labels, {}) + self.assertEqual(dataset.resource_tags, {}) def test_ctor_wo_project(self): resource = {"datasetReference": {"datasetId": "testdataset"}} From 120abc8aead1ddf6660ed8e3e76dda8373d38e38 Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Thu, 19 Dec 2024 16:38:24 +0100 Subject: [PATCH 02/10] fix: fix unittets --- dataset/pyvenv.cfg | 5 +++++ google/cloud/bigquery/dataset.py | 1 + tests/unit/test_dataset.py | 6 +----- 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 dataset/pyvenv.cfg diff --git a/dataset/pyvenv.cfg b/dataset/pyvenv.cfg new file mode 100644 index 000000000..1414a4c0b --- /dev/null +++ b/dataset/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /opt/homebrew/opt/python@3.12/bin +include-system-site-packages = false +version = 3.12.6 +executable = /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/bin/python3.12 +command = /opt/homebrew/opt/python@3.12/bin/python3.12 -m venv /Users/t985303/Desktop/Telenor/code/demo/forked/python-bigquery/dataset diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py index b896d4ab6..14c3bb12f 100644 --- a/google/cloud/bigquery/dataset.py +++ b/google/cloud/bigquery/dataset.py @@ -530,6 +530,7 @@ class Dataset(object): "storage_billing_model": "storageBillingModel", "max_time_travel_hours": "maxTimeTravelHours", "default_rounding_mode": "defaultRoundingMode", + "resource_tags": "resourceTags", } def __init__(self, dataset_ref) -> None: diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index 590ff0196..8319ad158 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -896,7 +896,6 @@ def test_location_setter(self): def test_resource_tags_update_in_place(self): dataset = self._make_one(self.DS_REF) - del dataset._properties["resourceTags"] # don't start w/ existing dict tags = dataset.resource_tags tags["123456789012/foo"] = "bar" # update in place self.assertEqual(dataset.resource_tags, {"123456789012/foo": "bar"}) @@ -904,7 +903,7 @@ def test_resource_tags_update_in_place(self): def test_resource_tags_setter(self): dataset = self._make_one(self.DS_REF) dataset.resource_tags = {"123456789012/foo": "bar"} - self.assertEqual(dataset.labels, {"123456789012/foo": "bar"}) + self.assertEqual(dataset.resource_tags, {"123456789012/foo": "bar"}) def test_resource_tags_setter_bad_value(self): dataset = self._make_one(self.DS_REF) @@ -1086,7 +1085,6 @@ def test_ctor(self): "datasetReference": {"projectId": project, "datasetId": dataset_id}, "friendlyName": "Data of the Test", "labels": {"some-stuff": "this-is-a-label"}, - "resourceTags": {"123456789012/foo": "bar"}, } dataset = self._make_one(resource) @@ -1097,7 +1095,6 @@ def test_ctor(self): self.assertEqual(dataset.reference.dataset_id, dataset_id) self.assertEqual(dataset.friendly_name, "Data of the Test") self.assertEqual(dataset.labels["some-stuff"], "this-is-a-label") - self.assertEqual(dataset.resource_tags["123456789012/foo"], "bar") def test_ctor_missing_properties(self): resource = { @@ -1109,7 +1106,6 @@ def test_ctor_missing_properties(self): self.assertIsNone(dataset.full_dataset_id) self.assertIsNone(dataset.friendly_name) self.assertEqual(dataset.labels, {}) - self.assertEqual(dataset.resource_tags, {}) def test_ctor_wo_project(self): resource = {"datasetReference": {"datasetId": "testdataset"}} From 3d03e739df5f50d387f6af779e553c70fe80dcb2 Mon Sep 17 00:00:00 2001 From: Lingqing Gan Date: Sat, 21 Dec 2024 06:41:47 +0800 Subject: [PATCH 03/10] Delete dataset/pyvenv.cfg --- dataset/pyvenv.cfg | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 dataset/pyvenv.cfg diff --git a/dataset/pyvenv.cfg b/dataset/pyvenv.cfg deleted file mode 100644 index 1414a4c0b..000000000 --- a/dataset/pyvenv.cfg +++ /dev/null @@ -1,5 +0,0 @@ -home = /opt/homebrew/opt/python@3.12/bin -include-system-site-packages = false -version = 3.12.6 -executable = /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/bin/python3.12 -command = /opt/homebrew/opt/python@3.12/bin/python3.12 -m venv /Users/t985303/Desktop/Telenor/code/demo/forked/python-bigquery/dataset From c56d0051c09146900e04d3e370faf4372667e9a0 Mon Sep 17 00:00:00 2001 From: Keunsoo Park <43742836+keunsoopark@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:54:15 +0100 Subject: [PATCH 04/10] Update google/cloud/bigquery/dataset.py Co-authored-by: Lingqing Gan --- google/cloud/bigquery/dataset.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py index 14c3bb12f..ed68d9779 100644 --- a/google/cloud/bigquery/dataset.py +++ b/google/cloud/bigquery/dataset.py @@ -806,10 +806,12 @@ def labels(self, value): def resource_tags(self): """Dict[str, str]: Resource tags of the dataset. - This method always returns a dict. To change a dataset's resource tags, - modify the dict, then call - :meth:`google.cloud.bigquery.client.Client.update_dataset`. To delete - a resource tag, set its value to :data:`None` before updating. + Optional. The tags attached to this dataset. Tag keys are globally + unique. Tag key is expected to be in the namespaced format, for + example "123456789012/environment" where 123456789012 is + the ID of the parent organization or project resource for this tag + key. Tag value is expected to be the short name, for example + "Production". Raises: ValueError: for invalid value types. From d26539f60074ac70fef55cb4ad50757c41f7b635 Mon Sep 17 00:00:00 2001 From: Keunsoo Park <43742836+keunsoopark@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:55:24 +0100 Subject: [PATCH 05/10] Update google/cloud/bigquery/dataset.py Co-authored-by: Lingqing Gan --- google/cloud/bigquery/dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py index ed68d9779..e6c084af4 100644 --- a/google/cloud/bigquery/dataset.py +++ b/google/cloud/bigquery/dataset.py @@ -820,7 +820,7 @@ def resource_tags(self): @resource_tags.setter def resource_tags(self, value): - if not isinstance(value, dict): + if not isinstance(value, dict) or value is not None: raise ValueError("Pass a dict") self._properties["resourceTags"] = value From c647485f36f304b33f5d1e9ee4752d7992459f13 Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Mon, 23 Dec 2024 11:40:25 +0100 Subject: [PATCH 06/10] added system tests & fix unittest for none --- bq-dataset-env/pyvenv.cfg | 5 +++++ google/cloud/bigquery/dataset.py | 2 +- tests/system/test_client.py | 24 +++++++++++++++++++++++- tests/unit/test_dataset.py | 4 +++- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 bq-dataset-env/pyvenv.cfg diff --git a/bq-dataset-env/pyvenv.cfg b/bq-dataset-env/pyvenv.cfg new file mode 100644 index 000000000..177c55d5b --- /dev/null +++ b/bq-dataset-env/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /opt/homebrew/opt/python@3.12/bin +include-system-site-packages = false +version = 3.12.6 +executable = /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/bin/python3.12 +command = /opt/homebrew/opt/python@3.12/bin/python3.12 -m venv /Users/t985303/Desktop/Telenor/code/demo/forked/python-bigquery/bq-dataset-env diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py index e6c084af4..4d06d729d 100644 --- a/google/cloud/bigquery/dataset.py +++ b/google/cloud/bigquery/dataset.py @@ -820,7 +820,7 @@ def resource_tags(self): @resource_tags.setter def resource_tags(self, value): - if not isinstance(value, dict) or value is not None: + if not isinstance(value, dict) and value is not None: raise ValueError("Pass a dict") self._properties["resourceTags"] = value diff --git a/tests/system/test_client.py b/tests/system/test_client.py index 95c679a14..47ca3ee9b 100644 --- a/tests/system/test_client.py +++ b/tests/system/test_client.py @@ -45,6 +45,8 @@ from google.cloud import storage from google.cloud.datacatalog_v1 import types as datacatalog_types from google.cloud.datacatalog_v1 import PolicyTagManagerClient +from google.cloud.resourcemanager_v3 import types as resourcemanager_types +from google.cloud.resourcemanager_v3 import TagKeysClient, TagValuesClient import psutil import pytest from test_utils.retry import RetryErrors @@ -159,6 +161,8 @@ def setUp(self): def tearDown(self): policy_tag_client = PolicyTagManagerClient() + tag_keys_client = TagKeysClient() + tag_values_client = TagValuesClient() def _still_in_use(bad_request): return any( @@ -178,6 +182,10 @@ def _still_in_use(bad_request): retry_in_use(Config.CLIENT.delete_table)(doomed) elif isinstance(doomed, datacatalog_types.Taxonomy): policy_tag_client.delete_taxonomy(name=doomed.name) + elif isinstance(doomed, resourcemanager_types.TagKey): + tag_keys_client.delete_tag_key(name=doomed.name).result() + elif isinstance(doomed, resourcemanager_types.TagValue): + tag_values_client.delete_tag_value(name=doomed.name).result() else: doomed.delete() @@ -284,11 +292,13 @@ def test_update_dataset(self): self.assertIsNone(dataset.friendly_name) self.assertIsNone(dataset.description) self.assertEqual(dataset.labels, {}) + self.assertEqual(dataset.resource_tags, {}) self.assertIs(dataset.is_case_insensitive, False) dataset.friendly_name = "Friendly" dataset.description = "Description" dataset.labels = {"priority": "high", "color": "blue"} + dataset.resource_tags = {"123456789012/key": "value", "123456789012/key1": "value1"} dataset.is_case_insensitive = True ds2 = Config.CLIENT.update_dataset( dataset, ("friendly_name", "description", "labels", "is_case_insensitive") @@ -296,6 +306,7 @@ def test_update_dataset(self): self.assertEqual(ds2.friendly_name, "Friendly") self.assertEqual(ds2.description, "Description") self.assertEqual(ds2.labels, {"priority": "high", "color": "blue"}) + self.assertEqual(ds2.resource_tags, {"123456789012/env": "prod", "123456789012/component": "batch"}) self.assertIs(ds2.is_case_insensitive, True) ds2.labels = { @@ -303,8 +314,19 @@ def test_update_dataset(self): "shape": "circle", # add "priority": None, # delete } - ds3 = Config.CLIENT.update_dataset(ds2, ["labels"]) + ds2.resource_tags = { + "123456789012/env": "dev", # change + "123456789012/project": "atlas", # add + "123456789012/component": None, # delete + } + ds3 = Config.CLIENT.update_dataset(ds2, ["labels", "resource_tags"]) self.assertEqual(ds3.labels, {"color": "green", "shape": "circle"}) + self.assertEqual(ds3.resource_tags, {"123456789012/env": "dev", "123456789012/project": "atlas"}) + + # Remove all tags + ds3.resource_tags = None + ds4 = Config.CLIENT.update_table(ds3, ["resource_tags"]) + self.assertEqual(ds4.resource_tags, {}) # If we try to update using d2 again, it will fail because the # previous update changed the ETag. diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index 8319ad158..46bcd6611 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -908,7 +908,9 @@ def test_resource_tags_setter(self): def test_resource_tags_setter_bad_value(self): dataset = self._make_one(self.DS_REF) with self.assertRaises(ValueError): - dataset.resource_tags = None + dataset.resource_tags = "invalid" + with self.assertRaises(ValueError): + dataset.resource_tags = 123 def test_resource_tags_getter_missing_value(self): dataset = self._make_one(self.DS_REF) From 3d317d1b0a182df7d7f9707e243a4081dcd783de Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Mon, 23 Dec 2024 11:43:18 +0100 Subject: [PATCH 07/10] add missing assert --- tests/system/test_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system/test_client.py b/tests/system/test_client.py index 47ca3ee9b..4f35d4be2 100644 --- a/tests/system/test_client.py +++ b/tests/system/test_client.py @@ -298,10 +298,10 @@ def test_update_dataset(self): dataset.friendly_name = "Friendly" dataset.description = "Description" dataset.labels = {"priority": "high", "color": "blue"} - dataset.resource_tags = {"123456789012/key": "value", "123456789012/key1": "value1"} + dataset.resource_tags = {"123456789012/env": "prod", "123456789012/component": "batch"} dataset.is_case_insensitive = True ds2 = Config.CLIENT.update_dataset( - dataset, ("friendly_name", "description", "labels", "is_case_insensitive") + dataset, ("friendly_name", "description", "labels", "resource_tags", "is_case_insensitive") ) self.assertEqual(ds2.friendly_name, "Friendly") self.assertEqual(ds2.description, "Description") From 359a9e19a8e853fae4f47aa73b031271cdbe8a69 Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Mon, 23 Dec 2024 11:44:52 +0100 Subject: [PATCH 08/10] remove venv --- bq-dataset-env/pyvenv.cfg | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 bq-dataset-env/pyvenv.cfg diff --git a/bq-dataset-env/pyvenv.cfg b/bq-dataset-env/pyvenv.cfg deleted file mode 100644 index 177c55d5b..000000000 --- a/bq-dataset-env/pyvenv.cfg +++ /dev/null @@ -1,5 +0,0 @@ -home = /opt/homebrew/opt/python@3.12/bin -include-system-site-packages = false -version = 3.12.6 -executable = /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/bin/python3.12 -command = /opt/homebrew/opt/python@3.12/bin/python3.12 -m venv /Users/t985303/Desktop/Telenor/code/demo/forked/python-bigquery/bq-dataset-env From ddb3bf6c6ed1833aadc90a71356cb451f85d5814 Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Tue, 7 Jan 2025 11:15:22 +0100 Subject: [PATCH 09/10] include resourcemanager in noxfile.py --- noxfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/noxfile.py b/noxfile.py index 750a6b459..e08956b11 100644 --- a/noxfile.py +++ b/noxfile.py @@ -219,6 +219,9 @@ def system(session): # Data Catalog needed for the column ACL test with a real Policy Tag. session.install("google-cloud-datacatalog", "-c", constraints_path) + # Resource Manager needed for test with a real Resource Tag. + session.install("google-cloud-resource-manager", "-c", constraints_path) + if session.python in ["3.11", "3.12"]: extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]" else: @@ -366,6 +369,7 @@ def prerelease_deps(session): session.install( "freezegun", "google-cloud-datacatalog", + "google-cloud-resource-manager", "google-cloud-storage", "google-cloud-testutils", "psutil", From 14e3e4777597d5767bfbbc0971f340ff925d5ea2 Mon Sep 17 00:00:00 2001 From: Park Keunsoo Date: Wed, 8 Jan 2025 18:59:40 +0100 Subject: [PATCH 10/10] fix fixture for tag keys --- tests/system/test_client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/system/test_client.py b/tests/system/test_client.py index 4f35d4be2..f76e4ca71 100644 --- a/tests/system/test_client.py +++ b/tests/system/test_client.py @@ -298,7 +298,7 @@ def test_update_dataset(self): dataset.friendly_name = "Friendly" dataset.description = "Description" dataset.labels = {"priority": "high", "color": "blue"} - dataset.resource_tags = {"123456789012/env": "prod", "123456789012/component": "batch"} + dataset.resource_tags = {f"{Config.CLIENT.project}/env": "prod", f"{Config.CLIENT.project}/component": "batch"} dataset.is_case_insensitive = True ds2 = Config.CLIENT.update_dataset( dataset, ("friendly_name", "description", "labels", "resource_tags", "is_case_insensitive") @@ -306,7 +306,7 @@ def test_update_dataset(self): self.assertEqual(ds2.friendly_name, "Friendly") self.assertEqual(ds2.description, "Description") self.assertEqual(ds2.labels, {"priority": "high", "color": "blue"}) - self.assertEqual(ds2.resource_tags, {"123456789012/env": "prod", "123456789012/component": "batch"}) + self.assertEqual(ds2.resource_tags, {f"{Config.CLIENT.project}/env": "prod", f"{Config.CLIENT.project}/component": "batch"}) self.assertIs(ds2.is_case_insensitive, True) ds2.labels = { @@ -315,13 +315,13 @@ def test_update_dataset(self): "priority": None, # delete } ds2.resource_tags = { - "123456789012/env": "dev", # change - "123456789012/project": "atlas", # add - "123456789012/component": None, # delete + f"{Config.CLIENT.project}/env": "dev", # change + f"{Config.CLIENT.project}/project": "atlas", # add + f"{Config.CLIENT.project}/component": None, # delete } ds3 = Config.CLIENT.update_dataset(ds2, ["labels", "resource_tags"]) self.assertEqual(ds3.labels, {"color": "green", "shape": "circle"}) - self.assertEqual(ds3.resource_tags, {"123456789012/env": "dev", "123456789012/project": "atlas"}) + self.assertEqual(ds3.resource_tags, {f"{Config.CLIENT.project}/env": "dev", f"{Config.CLIENT.project}/project": "atlas"}) # Remove all tags ds3.resource_tags = None