def test_get_active_time_active_20_minutes_with_changed_desk_state(): t1 = Timestamp(2018, 1, 1, 0, 0, 0) t2 = Timestamp(2018, 1, 1, 0, 10, 0) t3 = Timestamp(2018, 1, 1, 0, 20, 0) model = Model( StubDataStore(session_events=[(t1, ACTIVE)], desk_events=[(t2, UP)])) assert model.get_active_time(Timestamp.min, t3) == Timedelta(minutes=10)
def test_get_active_time_just_after_desk_change(): t1 = Timestamp(2018, 1, 1, 0, 0, 0) t2 = Timestamp(2018, 1, 1, 0, 10, 0) model = Model( StubDataStore(session_events=[(t1, ACTIVE)], desk_events=[(t2, UP)])) assert model.get_active_time(Timestamp.min, t2) == Timedelta(0)
def test_get_active_time_active_for_10_minutes(): t1 = Timestamp(2018, 1, 1, 0, 0, 0) t2 = Timestamp(2018, 1, 1, 0, 10, 0) model = Model(StubDataStore(session_events=[(t1, ACTIVE)], desk_events=[])) assert model.get_active_time(Timestamp.min, t2) == Timedelta(minutes=10)
def test_get_active_time_active_zero(): t = Timestamp(2018, 1, 1) model = Model(StubDataStore(session_events=[(t, ACTIVE)], desk_events=[])) assert model.get_active_time(Timestamp.min, t) == Timedelta(0)
def test_get_active_time_empty(): model = Model(StubDataStore.empty()) assert model.get_active_time(Timestamp.min, Timestamp.max) == Timedelta(0)