Skip to content

Commit 958a54d

Browse files
committed
Add test for expiration_time option
1 parent 4515289 commit 958a54d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

bigquery/tests/test_client.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
actual = 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

15391560
class TestCreateView(unittest.TestCase):
15401561

0 commit comments

Comments
 (0)