@@ -132,7 +132,7 @@ def test_parameter_ast(self):
132
132
},
133
133
"init" : {
134
134
"type" : "DateTimeLiteral" ,
135
- "value" : "2021-03-20T15:59:10.607352Z "
135
+ "value" : "2021-03-20T15:59:10.607352000Z "
136
136
},
137
137
"type" : "VariableAssignment"
138
138
},
@@ -150,7 +150,7 @@ def test_parameter_ast(self):
150
150
},
151
151
"init" : {
152
152
"type" : "DateTimeLiteral" ,
153
- "value" : "2021-03-20T15:59:10.607352Z "
153
+ "value" : "2021-03-20T15:59:10.607352000Z "
154
154
},
155
155
"type" : "VariableAssignment"
156
156
},
@@ -514,6 +514,22 @@ def test_profiler_mock(self):
514
514
'available' : 5727718400 , 'free' : 35330048 ,
515
515
'used' : 11452150784 })
516
516
517
+ def test_time_to_ast (self ):
518
+ from influxdb_client .extras import pd
519
+ import dateutil .parser
520
+
521
+ literals = [
522
+ (pd .Timestamp ('1996-02-25T21:20:00.001001231Z' ), '1996-02-25T21:20:00.001001231Z' ),
523
+ (dateutil .parser .parse ('1996-02-25T21:20:00.001001231Z' ), '1996-02-25T21:20:00.001001000Z' ),
524
+ (dateutil .parser .parse ('1996-02-25' ), '1996-02-25T00:00:00.000000000Z' ),
525
+ (datetime .datetime (2021 , 5 , 24 , 8 , 40 , 44 , 785000 , tzinfo = timezone .utc ), '2021-05-24T08:40:44.785000000Z' ),
526
+ ]
527
+
528
+ for literal in literals :
529
+ ast = QueryApi ._build_flux_ast ({'date' : literal [0 ]})
530
+ self .assertEqual ('DateTimeLiteral' , ast .body [0 ].assignment .init .type )
531
+ self .assertEqual (literal [1 ], ast .body [0 ].assignment .init .value )
532
+
517
533
518
534
if __name__ == '__main__' :
519
535
unittest .main ()
0 commit comments