Skip to content

Commit

Permalink
Add explicit test coverage for 'LoadJobConfig.skip_leading_rows'.
Browse files Browse the repository at this point in the history
Note question posted to issue #5093:  should 'max_bad_rows' and
'skip_leading_rows' match in how the mangle / parse the value in the
resource?  Docs say it is an integer.
  • Loading branch information
tseaver committed Oct 17, 2018
1 parent adf2710 commit 51aade2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,12 @@ def max_bad_records(self):
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.maxBadRecords
"""
# XXX: should this coerce from str, like 'skip_leading_rows' below?
return self._get_sub_prop('maxBadRecords')

@max_bad_records.setter
def max_bad_records(self, value):
# XXX: should this coerce to str, like 'skip_leading_rows' below?
self._set_sub_prop('maxBadRecords', value)

@property
Expand Down
25 changes: 25 additions & 0 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,31 @@ def test_quote_character_setter(self):
self.assertEqual(
config._properties['load']['quote'], quote_character)

def test_skip_leading_rows_missing(self):
config = self._get_target_class()()
self.assertIsNone(config.skip_leading_rows)

def test_skip_leading_rows_hit_w_str(self):
skip_leading_rows = 1
config = self._get_target_class()()
config._properties['load']['skipLeadingRows'] = str(skip_leading_rows)
self.assertEqual(config.skip_leading_rows, skip_leading_rows)

def test_skip_leading_rows_hit_w_integer(self):
skip_leading_rows = 1
config = self._get_target_class()()
config._properties['load']['skipLeadingRows'] = skip_leading_rows
self.assertEqual(config.skip_leading_rows, skip_leading_rows)

def test_skip_leading_rows_setter(self):
skip_leading_rows = 1
config = self._get_target_class()()
config.skip_leading_rows = skip_leading_rows
self.assertEqual(
config._properties['load']['skipLeadingRows'],
# XXX: Should this really be a str?
str(skip_leading_rows))

def test_schema(self):
from google.cloud.bigquery.schema import SchemaField
config = self._get_target_class()()
Expand Down

0 comments on commit 51aade2

Please sign in to comment.