11from pytrackunit .helper import *
2- def test_ma ():
3- testdata = []
4- testobject = {}
5- testobject ["val" ] = 2
6- for i in range (10 ):
7- testdata .append (testobject )
8- moving_avg (testdata ,"val" )
2+ def test_get_datetime ():
3+ dt = get_datetime ("2020-03-21T12:32:13.100000Z" )
4+ assert dt .date ().year == 2020
5+ assert dt .date ().month == 3
6+ assert dt .date ().day == 21
7+ assert dt .time ().hour == 12
8+ assert dt .time ().minute == 32
9+ assert dt .time ().second == 13
10+ assert dt .time ().microsecond == 100000
911def test_getsection_always_in_section ():
1012 dobj = {}
1113 dobj ['time' ] = '2021-06-18T13:18:18.0000000Z'
@@ -22,3 +24,24 @@ def test_getsection_min_section_len():
2224 indata [i ]['value' ] = i
2325 data = get_next_section (indata ,lambda x : x ['value' ] % 2 == 0 ,fendsec = None ,min_insec_len = 2 )
2426 assert data is None
27+ def test_ma ():
28+ testdata = []
29+ testobject = {}
30+ testobject ["val" ] = 2
31+ for i in range (10 ):
32+ testdata .append (testobject )
33+ moving_avg (testdata ,"val" )
34+ def test_get_timediff_1 ():
35+ arg1 = "2020-03-21T12:32:13.100000Z"
36+ arg2 = "2020-03-21T12:32:13.200000Z"
37+ dt = get_time_diff (arg1 ,arg2 )
38+ assert dt .days == 0
39+ assert dt .seconds == 0
40+ #assert dt.microseconds == 100000
41+ def test_get_timediff_2 ():
42+ arg1 = "2020-03-21T12:32:14.100000Z"
43+ arg2 = "2020-03-21T12:32:13.100000Z"
44+ dt = get_time_diff (arg1 ,arg2 )
45+ assert dt .days == 0
46+ assert dt .seconds == 1
47+ #assert dt.microseconds == 100000
0 commit comments