Ejemplo n.º 1
0
 def test_intersection_entire(self):
     now = datetime.now()
     tp1 = TimePeriod(now, now + timedelta(hours=1))
     tp2 = TimePeriod(now - timedelta(minutes=10),
                      now + timedelta(minutes=70))
     assert tp1.intersection(tp2).duration == timedelta(minutes=60)
     assert tp2.intersection(tp1).duration == timedelta(minutes=60)
Ejemplo n.º 2
0
def test_intersection_none():
    now = datetime.now()
    tp1 = TimePeriod(now, now + timedelta(hours=1))
    tp2 = TimePeriod(now - timedelta(hours=1), now)
    assert tp1.intersection(tp2) is None
    assert tp2.intersection(tp1) is None
def test_intersection_start():
    now = datetime.now()
    tp1 = TimePeriod(now, now + timedelta(hours=1))
    tp2 = TimePeriod(now - timedelta(minutes=10), now + timedelta(minutes=50))
    assert tp1.intersection(tp2).duration == timedelta(minutes=50)
    assert tp2.intersection(tp1).duration == timedelta(minutes=50)
def test_intersection_none():
    now = datetime.now()
    tp1 = TimePeriod(now, now + timedelta(hours=1))
    tp2 = TimePeriod(now - timedelta(hours=1), now)
    assert tp1.intersection(tp2) is None
    assert tp2.intersection(tp1) is None