Esempio n. 1
0
 def test_past_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
     ]
     vacay = VacationSegment(-10, -5, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(7, None, 3),
     ])
Esempio n. 2
0
 def test_idempotency(self):
     road = [
         Brick(0, 0, None),
         Brick(5, None, 3),
         Brick(10, None, 0),
         Brick(20, None, 1),
         Brick(31, None, 5),
     ]
     vacay = VacationSegment(5, 10, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), road)
Esempio n. 3
0
 def test_future_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
     ]
     vacay = VacationSegment(50, 100, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(7, None, 3),
     ])
Esempio n. 4
0
 def test_past_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, 7, None),
     ]
     vacay = VacationSegment(
         -10, -5, 0, config_pb2.VacationPattern.REACH_TOTAL_BEFORE_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(7, 7, None),
     ])
Esempio n. 5
0
 def test_future_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, 7, None),
     ]
     vacay = VacationSegment(
         50, 100, 0, config_pb2.VacationPattern.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(7, 7, None),
     ])
Esempio n. 6
0
 def test_future_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, 7, None),
     ]
     vacay = VacationSegment(50, 100, 0,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(7, 7, None),
     ])
Esempio n. 7
0
 def test_idempotency(self):
     road = [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(5, 5.0, None),
         Brick(10, None, 0),
         Brick(20, 20, None),
         Brick(30, 40, None),
     ]
     vacay = VacationSegment(
         5, 10, 0, config_pb2.VacationPattern.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), road)
Esempio n. 8
0
 def test_idempotency(self):
     road = [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(5, None, 1.0),
         Brick(10, None, 0),
         Brick(20, None, 1.0),
         Brick(30, 40, None),
     ]
     vacay = VacationSegment(5, 10, 0,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), road)
Esempio n. 9
0
 def test_vacation_into_the_future(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(20, None, 1),
     ]
     vacay = VacationSegment(5, 25, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, None, 3),
         Brick(20, None, 0),
     ])
Esempio n. 10
0
 def test_minimalist_road(self):
     road = [
         Brick(0, 0, None),
         Brick(20, None, 1),
     ]
     vacay = VacationSegment(5, 10, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, None, 1),
         Brick(10, None, 0),
         Brick(20, None, 1),
     ])
Esempio n. 11
0
 def test_minimalist_road(self):
     road = [
         Brick(0, 0, None),
         Brick(20, 20, None),
     ]
     vacay = VacationSegment(
         5, 10, 0, config_pb2.VacationPattern.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, 5.0, None),
         Brick(10, None, 0),
         Brick(20, 20, None),
     ])
Esempio n. 12
0
 def test_past_and_future_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(20, None, 1),
         Brick(30, None, 5),
         Brick(31, None, 5),
     ]
     vacay = VacationSegment(-50, 100, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(31, None, 0),
     ])
Esempio n. 13
0
 def test_vacation_into_the_future(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(20, 20, None),
     ]
     vacay = VacationSegment(
         5, 25, 0, config_pb2.VacationPattern.REACH_TOTAL_BEFORE_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, 20.0, None),
         Brick(20, None, 0),
     ])
Esempio n. 14
0
 def test_minimalist_road(self):
     road = [
         Brick(0, 0, None),
         Brick(20, 20, None),
     ]
     vacay = VacationSegment(5, 10, 0,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, None, 1),
         Brick(10, None, 0),
         Brick(20, None, 1),
     ])
Esempio n. 15
0
 def test_vacation_into_the_future(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(20, 20, None),
     ]
     vacay = VacationSegment(5, 25, 0,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, None, 1.0),
         Brick(20, None, 0),
     ])
Esempio n. 16
0
 def test_past_and_future_vacation(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(20, 20, None),
         Brick(30, None, 5),
         Brick(31, None, 5),
     ]
     vacay = VacationSegment(-50, 100, 0,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(31, None, 0),
     ])
Esempio n. 17
0
 def test_more_basics(self):
     road = [
         Brick(100, 55, None),
         Brick(107, None, 3),
         Brick(120, None, 1),
         Brick(130, None, 5),
         Brick(131, None, 5),
     ]
     vacay = VacationSegment(105, 110, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(100, 55, None),
         Brick(105, None, 3),
         Brick(110, None, 0),
         Brick(120, None, 1),
         Brick(131, None, 5),
     ])
Esempio n. 18
0
 def test_basics(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(20, None, 1),
         Brick(30, None, 5),
         Brick(31, None, 5),
     ]
     vacay = VacationSegment(5, 10, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, None, 3),
         Brick(10, None, 0),
         Brick(20, None, 1),
         Brick(31, None, 5),
     ])
Esempio n. 19
0
 def test_non_zero_rate(self):
     road = [
         Brick(100, 55, None),
         Brick(107, None, 3),
         Brick(120, None, 1),
         Brick(130, None, 5),
         Brick(131, None, 5),
     ]
     vacay = VacationSegment(105, 110, 999, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(100, 55, None),
         Brick(105, None, 3),
         Brick(110, None, 999),
         Brick(120, None, 1),
         Brick(131, None, 5),
     ])
Esempio n. 20
0
 def test_non_zero_rate(self):
     road = [
         Brick(100, 55, None),
         Brick(103, 61, None),
         Brick(120, 95, None),
         Brick(130, 115, None),
     ]
     vacay = VacationSegment(105, 110, 999,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(100, 55, None),
         Brick(103, 61, None),
         Brick(105, None, 2.0),
         Brick(110, None, 999),
         Brick(120, None, 2.0),
         Brick(130, 115, None),
     ])
Esempio n. 21
0
 def test_basics(self):
     road = [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(20, 20, None),
         Brick(30, 40, None),
     ]
     vacay = VacationSegment(
         5, 10, 0, config_pb2.VacationPattern.REACH_TOTAL_BEFORE_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(5, 10.0, None),
         Brick(10, None, 0),
         Brick(20, 20, None),
         Brick(30, 40, None),
     ])
Esempio n. 22
0
 def test_non_zero_rate(self):
     road = [
         Brick(100, 55, None),
         Brick(103, 61, None),
         Brick(120, 95, None),
         Brick(130, 115, None),
     ]
     vacay = VacationSegment(
         105, 110, 999,
         config_pb2.VacationPattern.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(100, 55, None),
         Brick(103, 61, None),
         Brick(105, 65.0, None),
         Brick(110, None, 999),
         Brick(120, 95, None),
         Brick(130, 115, None),
     ])
Esempio n. 23
0
 def test_more_basics(self):
     self.maxDiff = 100000
     road = [
         Brick(100, 55, None),
         Brick(103, 61, None),
         Brick(120, 95, None),
         Brick(130, 115, None),
     ]
     vacay = VacationSegment(
         105, 110, 0, config_pb2.VacationPattern.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(100, 55, None),
         Brick(103, 61, None),
         Brick(105, 65.0, None),
         Brick(110, None, 0),
         Brick(120, 95, None),
         Brick(130, 115, None),
     ])
Esempio n. 24
0
 def test_interior_rates(self):
     road = [
         Brick(0, 0, None),
         Brick(7, None, 3),
         Brick(8, None, 500),
         Brick(9, None, -999),
         Brick(10, None, 500),
         Brick(20, None, 1),
         Brick(30, None, 5),
         Brick(31, None, 5),
     ]
     vacay = VacationSegment(5, 10, 0, None)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, None, 3),
         Brick(10, None, 0),
         Brick(20, None, 1),
         Brick(31, None, 5),
     ])
Esempio n. 25
0
 def test_interior_rates(self):
     road = [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(8, None, 500),
         Brick(9, None, -999),
         Brick(10, None, 800),
         Brick(20, 20, None),
         Brick(30, 40, None),
     ]
     vacay = VacationSegment(5, 10, 0,
                             config_pb2.VacationPattern.DISCARD_TOTALS)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(5, None, 1.0),
         Brick(10, None, 0),
         Brick(20, None, 1.0),
         Brick(30, 40, None),
     ])
Esempio n. 26
0
 def test_interior_rates(self):
     self.maxDiff = 100000
     road = [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(8, None, 500),
         Brick(9, None, -999),
         Brick(10, None, 800),
         Brick(20, 20, None),
         Brick(30, 40, None),
     ]
     vacay = VacationSegment(
         5, 10, 0, config_pb2.VacationPattern.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(3, 3, None),
         Brick(5, 5.0, None),
         Brick(10, None, 0),
         Brick(20, 20, None),
         Brick(30, 40, None),
     ])