Skip to content

Commit 116de78

Browse files
committed
Revises test for additional clarity
1 parent 16e2c2c commit 116de78

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

tests/unit/test_dataset.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,16 @@ class TestDataset(unittest.TestCase):
650650
DS_ID = "dataset-id"
651651
DS_REF = DatasetReference(PROJECT, DS_ID)
652652
KMS_KEY_NAME = "projects/1/locations/us/keyRings/1/cryptoKeys/1"
653+
DEFAULT_STORAGE_LOCATION_URI = "gs://test-bucket/test-path"
654+
PARAMETERS = {"key": "value"}
655+
API_REPR = {
656+
"datasetReference": {"projectId": "project", "datasetId": "dataset-id"},
657+
"labels": {},
658+
"externalCatalogDatasetOptions": {
659+
"defaultStorageLocationUri": DEFAULT_STORAGE_LOCATION_URI,
660+
"parameters": PARAMETERS,
661+
},
662+
}
653663

654664
@staticmethod
655665
def _get_target_class():
@@ -1014,27 +1024,23 @@ def test_from_string_legacy_string(self):
10141024
with self.assertRaises(ValueError):
10151025
cls.from_string("string-project:string_dataset")
10161026

1017-
API_REPR = {
1018-
"datasetReference": {"projectId": "project", "datasetId": "dataset-id"},
1019-
"labels": {},
1020-
"externalCatalogDatasetOptions": {
1021-
"defaultStorageLocationUri": "gs://test-bucket/test-path",
1022-
"parameters": {"key": "value"},
1023-
},
1024-
}
1025-
10261027
def test_external_catalog_dataset_options_setter(self):
10271028
from google.cloud.bigquery.external_config import ExternalCatalogDatasetOptions
10281029

10291030
dataset = self._make_one(self.DS_REF)
1031+
1032+
# GIVEN the parameters DEFAULT_STORAGE_LOCATION_URI and PARAMETERS
1033+
# WHEN an ExternalCatalogDatasetOptions obj is created
1034+
# and added to a dataset.
10301035
ecdo_obj = ExternalCatalogDatasetOptions(
1031-
default_storage_location_uri="gs://test-bucket/test-path",
1032-
parameters={"key": "value"},
1036+
default_storage_location_uri=self.DEFAULT_STORAGE_LOCATION_URI,
1037+
parameters=self.PARAMETERS,
10331038
)
1034-
10351039
dataset.external_catalog_dataset_options = ecdo_obj
1036-
expected = self.API_REPR
1040+
1041+
# THEN the api representation of the dataset will match API_REPR
10371042
result = dataset.to_api_repr()
1043+
expected = self.API_REPR
10381044
assert result == expected
10391045

10401046
def test_external_catalog_dataset_options_getter(self):
@@ -1067,8 +1073,6 @@ def test_external_catalog_dataset_options_to_api_repr(self):
10671073
expected = resource["externalCatalogDatasetOptions"]
10681074
assert result == expected
10691075

1070-
1071-
10721076
def test__build_resource_w_custom_field(self):
10731077
dataset = self._make_one(self.DS_REF)
10741078
dataset._properties["newAlphaProperty"] = "unreleased property"

tests/unit/test_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ def test_to_api_repr(self):
12501250
}
12511251

12521252
assert storage_descriptor.to_api_repr() == expected_repr
1253+
12531254
# TODO: needs a from_api_repr() test.
12541255

12551256

@@ -1314,4 +1315,4 @@ def test_to_api_repr(self):
13141315
}
13151316
assert serde_info.to_api_repr() == expected_repr
13161317

1317-
# TODO: needs a from_api_repr() test.
1318+
# TODO: needs a from_api_repr() test.

0 commit comments

Comments
 (0)