Example #1
0
    def test_timeCheck(self):
        #self.resetEngine()
        pengine = self.pengine
        atom = self.atom
        pengine.window_size = 10000

        # case 1: t0 < t1
        pengine.t_0 = 0
        pengine.t_1 = 10000
        assert pengine.timeCheck(atom) == 0, 'a_time = t0'
        atom.last_timestamp = int((pengine.t_0 + pengine.t_1) / 2)
        assert pengine.timeCheck(atom) == 0, 't0 < a_time < t1'
        atom.last_timestamp = int(pengine.t_1)
        assert pengine.timeCheck(atom) == 0, 'a_time = t1'
        atom.last_timestamp = int(pengine.t_1 + 10)
        assert pengine.timeCheck(atom) == 1, 'a_time > t1'
        
        # case 2: t1 < t0 (wrap around)
        pengine.t_0 = 99235959
        pengine.t_1 = p_engine.timeIncrement(pengine.t_0)
        atom.last_timestamp =  int(pengine.t_0)
        assert pengine.timeCheck(atom) == 0, 'a_time = t0'
        atom.last_timestamp = int(pengine.t_1 - 10)
        assert pengine.timeCheck(atom) == 0, 'a_time < t0 < t1'
        atom.last_timestamp = int(pengine.t_1)
        assert pengine.timeCheck(atom) == 0, 'a_time = t1'
        atom.last_timestamp = int(pengine.t_1 + 10)
        assert pengine.timeCheck(atom) == 1, 't1 < a_time < t0'
Example #2
0
 def test_timeIncrement(self):
     for h in range(0,230000,10000):
         for m in range(0,5900,100):
             for s in range(0,59):
                 if h == 230000 and mmss == 0:
                     assert p_engine.timeIncrement(h+m+s) == 240000, "230000 bumped"
                 elif h == 240000 and mmss == 0:
                     assert p_engine.timeIncrement(h+m+s) == 0, "day bumped"
                 elif h == 230000:
                     assert p_engine.timeIncrement(h+m+s) == m+s, "day bumped"
                 else:
                     assert p_engine.timeIncrement(h+m+s) == h+10000+m+s, "hour bumped"
     assert p_engine.timeIncrement(10000) == 20000, 'hours place'
     assert p_engine.timeIncrement(10412) == 20412, 'with mmss != 0'
     assert p_engine.timeIncrement(230000) == 240000, 'wrap around'
     assert p_engine.timeIncrement(230576) == 576, 'wrap around w/ mmss'