@@ -1115,11 +1115,24 @@ def _get_target_class():
1115
1115
def _make_one (self , * args , ** kw ):
1116
1116
return self ._get_target_class ()(* args , ** kw )
1117
1117
1118
+ def _setUpConstants (self ):
1119
+ import datetime
1120
+ from google .cloud ._helpers import UTC
1121
+
1122
+ self .WHEN_TS = 1437767599.125
1123
+ self .WHEN = datetime .datetime .utcfromtimestamp (self .WHEN_TS ).replace (tzinfo = UTC )
1124
+ self .EXP_TIME = datetime .datetime (2015 , 8 , 1 , 23 , 59 , 59 , tzinfo = UTC )
1125
+
1118
1126
def test_ctor (self ):
1127
+ from google .cloud ._helpers import _millis
1128
+
1129
+ self ._setUpConstants ()
1119
1130
project = "test-project"
1120
1131
dataset_id = "test_dataset"
1121
1132
table_id = "coffee_table"
1122
1133
resource = {
1134
+ "creationTime" : self .WHEN_TS * 1000 ,
1135
+ "expirationTime" : _millis (self .EXP_TIME ),
1123
1136
"kind" : "bigquery#table" ,
1124
1137
"id" : "{}:{}.{}" .format (project , dataset_id , table_id ),
1125
1138
"tableReference" : {
@@ -1138,6 +1151,9 @@ def test_ctor(self):
1138
1151
}
1139
1152
1140
1153
table = self ._make_one (resource )
1154
+
1155
+ self .assertEqual (table .created , self .WHEN )
1156
+ self .assertEqual (table .expires , self .EXP_TIME )
1141
1157
self .assertEqual (table .project , project )
1142
1158
self .assertEqual (table .dataset_id , dataset_id )
1143
1159
self .assertEqual (table .table_id , table_id )
@@ -1204,6 +1220,8 @@ def test_ctor_missing_properties(self):
1204
1220
self .assertEqual (table .project , "testproject" )
1205
1221
self .assertEqual (table .dataset_id , "testdataset" )
1206
1222
self .assertEqual (table .table_id , "testtable" )
1223
+ self .assertIsNone (table .created )
1224
+ self .assertIsNone (table .expires )
1207
1225
self .assertIsNone (table .full_table_id )
1208
1226
self .assertIsNone (table .friendly_name )
1209
1227
self .assertIsNone (table .table_type )
0 commit comments