@@ -2104,6 +2104,47 @@ def test_push_success(self):
21042104 self .mock_table_data .insertAll .return_value .execute .assert_has_calls (
21052105 execute_calls )
21062106
2107+ def test_request_data_with_options (self ):
2108+ """Ensure that insertAll body has optional property only when
2109+ the optional parameter of push_rows passed.
2110+ """
2111+ expected_body = self .data .copy ()
2112+
2113+ self .client .push_rows (
2114+ self .dataset , self .table , self .rows ,
2115+ insert_id_key = 'one' )
2116+ self .mock_table_data .insertAll .assert_called_with (
2117+ projectId = self .project ,
2118+ datasetId = self .dataset ,
2119+ tableId = self .table ,
2120+ body = expected_body )
2121+
2122+ self .client .push_rows (
2123+ self .dataset , self .table , self .rows ,
2124+ insert_id_key = 'one' ,
2125+ ignore_unknown_values = False ,
2126+ skip_invalid_rows = False )
2127+ expected_body ['ignoreUnknownValues' ] = False
2128+ expected_body ['skipInvalidRows' ] = False
2129+ self .mock_table_data .insertAll .assert_called_with (
2130+ projectId = self .project ,
2131+ datasetId = self .dataset ,
2132+ tableId = self .table ,
2133+ body = expected_body )
2134+
2135+ self .client .push_rows (
2136+ self .dataset , self .table , self .rows ,
2137+ insert_id_key = 'one' ,
2138+ ignore_unknown_values = True ,
2139+ skip_invalid_rows = True )
2140+ expected_body ['ignoreUnknownValues' ] = True
2141+ expected_body ['skipInvalidRows' ] = True
2142+ self .mock_table_data .insertAll .assert_called_with (
2143+ projectId = self .project ,
2144+ datasetId = self .dataset ,
2145+ tableId = self .table ,
2146+ body = expected_body )
2147+
21072148
21082149class TestGetAllTables (unittest .TestCase ):
21092150
0 commit comments