@@ -54,43 +54,35 @@ def testMAdd(self):
5454
5555 rts .create ('a' )
5656 self .assertEqual ([1 , 2 , 3 ], rts .madd ([('a' , 1 , 5 ), ('a' , 2 , 10 ), ('a' , 3 , 15 )]))
57- res = rts .madd ([('a' , '*' , 5 ), ('a' , '*' , 10 ), ('a' , '*' , 15 )])
58- self .assertTrue (res [0 ] + 10 >= res [2 ])
5957
6058 def testIncrbyDecrby (self ):
6159 '''Test TS.INCRBY and TS.DECRBY calls'''
6260
6361 #test without counter reset
6462 for _ in range (100 ):
6563 self .assertTrue (rts .incrby (1 ,1 ))
64+ sleep (0.001 )
6665 self .assertEqual (100 , rts .get (1 )[1 ])
6766 for _ in range (100 ):
6867 self .assertTrue (rts .decrby (1 ,1 ))
68+ sleep (0.001 )
6969 self .assertEqual (0 , rts .get (1 )[1 ])
7070
71- #test with counter reset
72- for _ in range (50 ):
73- self .assertTrue (rts .incrby (1 ,1 ,time_bucket = 100 ))
74- self .assertTrue (rts .decrby (2 ,1 ,time_bucket = 100 ))
75- sleep (0.2 )
76- self .assertTrue (rts .incrby (1 ,1 ,time_bucket = 1 ))
77- self .assertEqual (1 , rts .get (1 )[1 ])
78- self .assertTrue (rts .decrby (2 ,1 ,time_bucket = 1 ))
79- self .assertEqual (- 1 , rts .get (2 )[1 ])
80-
8171 def testCreateRule (self ):
8272 '''Test TS.CREATERULE and TS.DELETERULE calls'''
8373
8474 # test rule creation
75+ time = 100
8576 rts .create (1 )
8677 rts .create (2 )
87- rts .createrule (1 , 2 , 'avg' , 1000 )
88- for _ in range (50 ):
89- rts .add (1 , '*' , 1 )
90- rts .add (1 , '*' , 2 )
78+ rts .createrule (1 , 2 , 'avg' , 100 )
79+ for i in range (50 ):
80+ rts .add (1 , time + i * 2 , 1 )
81+ rts .add (1 , time + i * 2 + 1 , 2 )
82+ rts .add (1 , time * 2 , 1.5 )
9183 self .assertAlmostEqual (rts .get (2 )[1 ], 1.5 )
9284 info = rts .info (1 )
93- self .assertEqual (info .rules [0 ][1 ], 1000 )
85+ self .assertEqual (info .rules [0 ][1 ], 100 )
9486
9587 # test rule deletion
9688 rts .deleterule (1 , 2 )
0 commit comments