Beispiel #1
0
 def test_it_does_not_encompass_other_range(self):
     range1 = DateRange(self.date3, self.date4)
     left_disjoint = DateRange(self.date1, self.date2)
     right_disjoint = DateRange(self.date5, self.date5)
     left_intersect = DateRange(self.date1, self.date3)
     right_intersect = DateRange(self.date3, self.date6)
     
     self.assertFalse(range1.encompasses(left_disjoint))
     self.assertFalse(range1.encompasses(right_disjoint))
     self.assertFalse(range1.encompasses(left_intersect))
     self.assertFalse(range1.encompasses(right_intersect))
Beispiel #2
0
 def test_it_is_not_encompassed_by_other_range(self):
     range1 = DateRange(self.date3, self.date4)
     left_disjoint = DateRange(self.date1, self.date2)
     right_disjoint = DateRange(self.date5, self.date5)
     left_intersect = DateRange(self.date1, self.date3)
     right_intersect = DateRange(self.date3, self.date6)
     
     self.assertFalse(left_disjoint.encompassed_by(range1))
     self.assertFalse(right_disjoint.encompassed_by(range1))
     self.assertFalse(left_intersect.encompassed_by(range1))
     self.assertFalse(right_intersect.encompassed_by(range1))
Beispiel #3
0
 def test_it_returns_the_intersection_of_disjoint_ranges(self):
     range1 = DateRange(self.date1, self.date2)
     range2 = DateRange(self.date3, self.date4)
     self.assertTrue(range1.intersection(range2) is None)
Beispiel #4
0
 def test_it_returns_the_intersection_of_two_equal_ranges(self):
     range1 = DateRange(self.date1, self.date3)
     range2 = DateRange(self.date1, self.date3)
     range3 = DateRange(self.date1, self.date3)
     self.assertEqual(range1.intersection(range2), range3)
Beispiel #5
0
 def test_it_is_not_disjoint_from_another_range(self):
     range1 = DateRange(self.date1, self.date2)
     range2 = DateRange(self.date2, self.date4)
     self.assertFalse(range1.disjoint(range2))
Beispiel #6
0
 def test_it_returns_the_rightmost_range(self):
     range1 = DateRange(self.date1, self.date3)
     range2 = DateRange(self.date3, self.date4)
     self.assertEqual(range1.rightmost(range2), range2)    
Beispiel #7
0
 def test_it_is_encompassed_by_other_range(self):
     range1 = DateRange(self.date2, self.date4)
     range2 = DateRange(self.date1, self.date4)
     self.assertTrue(range1.encompassed_by(range2))
Beispiel #8
0
 def test_it_iterates_the_days_between_two_dates(self):
     range = DateRange(self.date1, self.date6)
     expected = [ date(2015, 1, 1), date(2015, 1, 2), date(2015, 1, 3) ]
     result = [ day for day in range.iterdates() ]
     self.assertEqual(expected, result)
Beispiel #9
0
 def test_it_intersects(self):
     range1 = DateRange(self.date3, self.date4)
     range2 = DateRange(self.date1, self.date3)
     self.assertTrue(range1.intersection(range2))
Beispiel #10
0
 def test_it_returns_the_intersection_with_a_range(self):
     range1 = DateRange(self.date3, self.date4)
     range2 = DateRange(self.date1, self.date3)
     range3 = DateRange(self.date3, self.date3)
     self.assertEqual(range1.intersection(range2), range3)