From 5171f5483f1b1d6d13d369744b10916ae9914d24 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 30 Nov 2015 11:41:51 -0800 Subject: [PATCH] Updating Bigquery system test to verify timestamp handling. --- system_tests/bigquery.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/system_tests/bigquery.py b/system_tests/bigquery.py index 06db634346cc..b5114187c464 100644 --- a/system_tests/bigquery.py +++ b/system_tests/bigquery.py @@ -191,11 +191,17 @@ def test_update_table(self): self.assertEqual(found.mode, expected.mode) def test_load_table_then_dump_table(self): + import datetime + from gcloud._helpers import UTC + + NOW_SECONDS = 1448911495.484366 + NOW = datetime.datetime.utcfromtimestamp( + NOW_SECONDS).replace(tzinfo=UTC) ROWS = [ - ('Phred Phlyntstone', 32), - ('Bharney Rhubble', 33), - ('Wylma Phlyntstone', 29), - ('Bhettye Rhubble', 27), + ('Phred Phlyntstone', 32, NOW), + ('Bharney Rhubble', 33, NOW + datetime.timedelta(seconds=10)), + ('Wylma Phlyntstone', 29, NOW + datetime.timedelta(seconds=20)), + ('Bhettye Rhubble', 27, None), ] ROW_IDS = range(len(ROWS)) dataset = CLIENT.dataset(DATASET_NAME) @@ -206,7 +212,8 @@ def test_load_table_then_dump_table(self): full_name = bigquery.SchemaField('full_name', 'STRING', mode='REQUIRED') age = bigquery.SchemaField('age', 'INTEGER', mode='REQUIRED') - table = dataset.table(TABLE_NAME, schema=[full_name, age]) + now = bigquery.SchemaField('now', 'TIMESTAMP') + table = dataset.table(TABLE_NAME, schema=[full_name, age, now]) self.assertFalse(table.exists()) table.create() self.to_delete.insert(0, table)