Skip to content

Commit 5a9290a

Browse files
committed
Add tests
1 parent 218b842 commit 5a9290a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

bigquery/tests/test_client.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,47 @@ def test_push_success(self):
21082108
self.mock_table_data.insertAll.return_value.execute.assert_has_calls(
21092109
execute_calls)
21102110

2111+
def test_request_data_with_options(self):
2112+
"""Ensure that insertAll body has optional property only when
2113+
the optional parameter of push_rows passed.
2114+
"""
2115+
expected_body = self.data.copy()
2116+
2117+
self.client.push_rows(
2118+
self.dataset, self.table, self.rows,
2119+
insert_id_key='one')
2120+
self.mock_table_data.insertAll.assert_called_with(
2121+
projectId=self.project,
2122+
datasetId=self.dataset,
2123+
tableId=self.table,
2124+
body=expected_body)
2125+
2126+
self.client.push_rows(
2127+
self.dataset, self.table, self.rows,
2128+
insert_id_key='one',
2129+
ignore_unknown_values=False,
2130+
skip_invalid_rows=False)
2131+
expected_body['ignoreUnknownValues'] = False
2132+
expected_body['skipInvalidRows'] = False
2133+
self.mock_table_data.insertAll.assert_called_with(
2134+
projectId=self.project,
2135+
datasetId=self.dataset,
2136+
tableId=self.table,
2137+
body=expected_body)
2138+
2139+
self.client.push_rows(
2140+
self.dataset, self.table, self.rows,
2141+
insert_id_key='one',
2142+
ignore_unknown_values=True,
2143+
skip_invalid_rows=True)
2144+
expected_body['ignoreUnknownValues'] = True
2145+
expected_body['skipInvalidRows'] = True
2146+
self.mock_table_data.insertAll.assert_called_with(
2147+
projectId=self.project,
2148+
datasetId=self.dataset,
2149+
tableId=self.table,
2150+
body=expected_body)
2151+
21112152

21122153
class TestGetAllTables(unittest.TestCase):
21132154

0 commit comments

Comments
 (0)