Skip to content

Commit

Permalink
Cover the path of schema provided in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Aug 22, 2019
1 parent 919d30e commit 92b4653
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bigquery/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5618,8 +5618,9 @@ def test_load_table_from_json_basic_use(self):
assert sent_config.autodetect

def test_load_table_from_json_non_default_args(self):
from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES
from google.cloud.bigquery import job
from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES
from google.cloud.bigquery.schema import SchemaField

client = self._make_client()

Expand All @@ -5628,7 +5629,12 @@ def test_load_table_from_json_non_default_args(self):
{"name": "Two", "age": 22, "birthday": "1997-08-09", "adult": True},
]

job_config = job.LoadJobConfig()
schema = [
SchemaField("name", "STRING"),
SchemaField("age", "INTEGER"),
SchemaField("adult", "BOOLEAN"),
]
job_config = job.LoadJobConfig(schema=schema)

load_patch = mock.patch(
"google.cloud.bigquery.client.Client.load_table_from_file", autospec=True
Expand Down Expand Up @@ -5658,7 +5664,7 @@ def test_load_table_from_json_non_default_args(self):
sent_config = load_table_from_file.mock_calls[0][2]["job_config"]
assert job_config.source_format is None # the original was not modified
assert sent_config.source_format == job.SourceFormat.NEWLINE_DELIMITED_JSON
assert sent_config.schema is None
assert sent_config.schema == schema
assert sent_config.autodetect

# Low-level tests
Expand Down

0 comments on commit 92b4653

Please sign in to comment.