Skip to content

Commit

Permalink
add a test for extact timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoboro committed Mar 13, 2018
1 parent bfcef95 commit aba23d0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pandas_gbq/tests/test_gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,31 @@ def test_upload_data_with_missing_schema_fields_raises_error(self):
private_key=self.credentials,
table_schema=test_schema)

def test_upload_data_with_timestamp(self):
df = tm.makeMixedDataFrame()
test_id = "21"
test_size = 6
df = DataFrame(np.random.randn(test_size, 4), index=range(test_size),
columns=list('ABCD'))
test_timestamp = datetime.now(pytz.timezone('UTC'))
df['times'] = test_timestamp

gbq.to_gbq(
df, self.destination_table + test_id,
_get_project_id(),
private_key=self.credentials)

result_df = gbq.read_gbq("SELECT * FROM {0}".format(
self.destination_table + test_id),
project_id=_get_project_id(),
private_key=self.credentials)

assert len(result_df) == test_size

expected = df['times'].astype('M8[ns]').sort_values()
result = result_df['times'].astype('M8[ns]').sort_values()
tm.assert_numpy_array_equal(expected.values, result.values)

def test_list_dataset(self):
dataset_id = self.dataset_prefix + "1"
assert dataset_id in self.dataset.datasets()
Expand Down

0 comments on commit aba23d0

Please sign in to comment.