@@ -65,7 +65,7 @@ def test_initialize_readonly(self, mock_build, mock_return_cred):
6565 mock_return_cred .assert_called_once_with ()
6666 mock_cred .assert_called_once_with (service_account , key ,
6767 scope = BIGQUERY_SCOPE_READ_ONLY )
68- mock_cred .authorize .assert_called_once ( )
68+ self . assertTrue ( mock_cred .return_value . authorize .called )
6969 mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
7070 self .assertEquals (mock_bq , bq_client .bigquery )
7171 self .assertEquals (project_id , bq_client .project_id )
@@ -95,7 +95,7 @@ def test_initialize_read_write(self, mock_build, mock_return_cred):
9595 mock_return_cred .assert_called_once_with ()
9696 mock_cred .assert_called_once_with (service_account , key ,
9797 scope = BIGQUERY_SCOPE )
98- mock_cred .authorize .assert_called_once ( )
98+ self . assertTrue ( mock_cred .return_value . authorize .called )
9999 mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
100100 self .assertEquals (mock_bq , bq_client .bigquery )
101101 self .assertEquals (project_id , bq_client .project_id )
@@ -130,7 +130,7 @@ def test_initialize_key_file(self, mock_open, mock_build,
130130 mock_return_cred .assert_called_once_with ()
131131 mock_cred .assert_called_once_with (service_account , key ,
132132 scope = BIGQUERY_SCOPE )
133- mock_cred .authorize .assert_called_once ( )
133+ self . assertTrue ( mock_cred .return_value . authorize .called )
134134 mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
135135 self .assertEquals (mock_bq , bq_client .bigquery )
136136 self .assertEquals (project_id , bq_client .project_id )
@@ -378,7 +378,7 @@ def test_get_response(self):
378378 projectId = self .project_id , jobId = job_id , startIndex = offset ,
379379 maxResults = limit , pageToken = page_token , timeoutMs = 1000 )
380380
381- mock_query_job .execute .assert_called_once ()
381+ mock_query_job .execute .assert_called_once_with ()
382382 self .assertEquals (actual , mock_query_reply )
383383
384384
@@ -1482,6 +1482,7 @@ def setUp(self):
14821482 'tableId' : self .table , 'projectId' : self .project ,
14831483 'datasetId' : self .dataset }
14841484 }
1485+ self .expiration_time = 1437513693000
14851486
14861487 def test_table_create_failed (self ):
14871488 """Ensure that if creating the table fails, False is returned,
@@ -1535,6 +1536,26 @@ def test_table_create_success(self):
15351536
15361537 self .mock_tables .insert .return_value .execute .assert_called_with ()
15371538
1539+ def test_table_create_body_with_expiration_time (self ):
1540+ """Ensure that if expiration_time has specified,
1541+ it passed to the body."""
1542+
1543+ self .mock_tables .insert .return_value .execute .side_effect = [{
1544+ 'status' : 'foo' }, {'status' : 'bar' }]
1545+
1546+ self .client .create_table (self .dataset , self .table ,
1547+ self .schema , self .expiration_time )
1548+
1549+ body = self .body .copy ()
1550+ body .update ({
1551+ 'expirationTime' : self .expiration_time
1552+ })
1553+
1554+ self .mock_tables .insert .assert_called_with (
1555+ projectId = self .project , datasetId = self .dataset , body = body )
1556+
1557+ self .mock_tables .insert .return_value .execute .assert_called_with ()
1558+
15381559
15391560class TestCreateView (unittest .TestCase ):
15401561
0 commit comments