Skip to content

Commit a93a98c

Browse files
committed
updates to ensure coverage of external_config.py
1 parent f8ae243 commit a93a98c

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

google/cloud/bigquery/external_config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,9 @@ def schema(self, value):
905905

906906
@property
907907
def time_zone(self) -> Optional[str]:
908-
"""Optional[str]: Default time zone that will apply when parsing
909-
timestamp values that have no specific time zone.
910-
911-
(Valid for CSV and NEWLINE_DELIMITED_JSON)
908+
"""Optional[str]: Time zone used when parsing timestamp values that do not
909+
have specific time zone information (e.g. 2024-04-20 12:34:56). The expected
910+
format is an IANA timezone string (e.g. America/Los_Angeles).
912911
913912
See:
914913
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.time_zone

google/cloud/bigquery/job/load.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,9 @@ def source_format(self, value):
550550
self._set_sub_prop("sourceFormat", value)
551551

552552
@property
553-
def time_zone(self):
553+
def time_zone(self) -> Optional[str]:
554554
"""Optional[str]: Default time zone that will apply when parsing timestamp
555-
values that have no specific time zone. This option is valid for CSV and
556-
JSON sources.
555+
values that have no specific time zone.
557556
558557
See:
559558
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationLoad.FIELDS.time_zone

tests/unit/test_external_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ def test_schema_empty(self):
144144
want = {"sourceFormat": "", "schema": {"fields": []}}
145145
self.assertEqual(got, want)
146146

147+
def test_source_column_match_None(self):
148+
ec = external_config.ExternalConfig("")
149+
ec.source_column_match = None
150+
expected = None
151+
result = ec.source_column_match
152+
self.assertEqual(expected, result)
153+
154+
def test_source_column_match_valid_input(self):
155+
ec = external_config.ExternalConfig("")
156+
ec.source_column_match = SourceColumnMatch.NAME
157+
expected = "NAME"
158+
result = ec.source_column_match
159+
self.assertEqual(expected, result)
160+
147161
def _verify_base(self, ec):
148162
self.assertEqual(ec.autodetect, True)
149163
self.assertEqual(ec.compression, "compression")

0 commit comments

Comments
 (0)