Skip to content

Commit b7eabe1

Browse files
committed
Updates docstrings and tests
1 parent c31b1ad commit b7eabe1

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

google/cloud/bigquery/external_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,9 @@ def source_column_match(self) -> Optional[SourceColumnMatch]:
496496
"""
497497

498498
value = self._properties.get("sourceColumnMatch")
499-
if value is not None:
500-
return SourceColumnMatch(value)
501-
return None
499+
# if value is not None:
500+
return SourceColumnMatch(value) if value is not None else None
501+
# return None
502502

503503
@source_column_match.setter
504504
def source_column_match(self, value: Optional[SourceColumnMatch]):

tests/unit/test_external_config.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,6 @@ 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-
161147
def _verify_base(self, ec):
162148
self.assertEqual(ec.autodetect, True)
163149
self.assertEqual(ec.compression, "compression")
@@ -900,7 +886,7 @@ def test_to_api_repr(self):
900886
)
901887

902888

903-
class CSVOptions(unittest.TestCase):
889+
class TestCSVOptions(unittest.TestCase):
904890
SOURCE_COLUMN_MATCH = SourceColumnMatch.NAME
905891

906892
def test_to_api_repr(self):
@@ -930,6 +916,28 @@ def test_to_api_repr(self):
930916
},
931917
)
932918

919+
def test_source_column_match_None(self):
920+
ec = external_config.CSVOptions()
921+
ec.source_column_match = None
922+
expected = None
923+
result = ec.source_column_match
924+
self.assertEqual(expected, result)
925+
926+
def test_source_column_match_valid_input(self):
927+
ec = external_config.CSVOptions()
928+
ec.source_column_match = SourceColumnMatch.NAME
929+
expected = "NAME"
930+
result = ec.source_column_match
931+
self.assertEqual(expected, result)
932+
933+
def test_source_column_match_invalid_input(self):
934+
ec = external_config.CSVOptions()
935+
with self.assertRaisesRegex(
936+
TypeError,
937+
"value must be a google.cloud.bigquery.enums.SourceColumnMatch or None",
938+
):
939+
ec.source_column_match = "neither None or enum value"
940+
933941

934942
class TestGoogleSheetsOptions(unittest.TestCase):
935943
def test_to_api_repr(self):

0 commit comments

Comments
 (0)