def test_pop_until(): timeline = Timeline([('event 1', 1.), ('event 2', .5)]) events = timeline.pop_until(.2) assert_list_equal([], events) assert_equal(.2, timeline.time) events = timeline.pop_until(1.) assert_list_equal(['event 2', 'event 1', 'event 2'], events) assert_equal(1., timeline.time)
def test_pop_until(): timeline = Timeline([("event 1", 1.0), ("event 2", 0.5)]) events = timeline.pop_until(0.2) assert events == [] assert timeline.time == approx(0.2) events = timeline.pop_until(1.0) assert events == ["event 2", "event 1", "event 2"] assert timeline.time == approx(1.0)
def test_one_time_event(): timeline = Timeline([ ('recurring-event', 1.), ]) timeline.add_one_time_event('one-timer', .1) events = timeline.pop_until(2.) assert_list_equal(events, ['one-timer', 'recurring-event', 'recurring-event'])
def test_non_zero_start(): timeline = Timeline([("event 1", 1.0), ("event 2", 0.25)], start=-1) assert timeline.time_of_next_event == approx(-0.75) assert timeline.pop_until(0.0) == [ "event 2", "event 2", "event 2", "event 1", "event 2", ]
def test_non_zero_start(): timeline = Timeline([('event 1', 1.), ('event 2', .25)], start=-1) assert_equal(timeline.time_of_next_event, -.75) assert_list_equal(timeline.pop_until(0.), ['event 2', 'event 2', 'event 2', 'event 1', 'event 2'])
def test_one_time_event(): timeline = Timeline([("recurring-event", 1.0)]) timeline.add_one_time_event("one-timer", 0.1) events = timeline.pop_until(2.0) assert events == ["one-timer", "recurring-event", "recurring-event"]