示例#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),
     ])
示例#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)
示例#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),
     ])
示例#4
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),
     ])
示例#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),
     ])
示例#6
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),
     ])
示例#7
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),
     ])
示例#8
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),
     ])
示例#9
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),
     ])
示例#10
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_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),
     ])
示例#11
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),
     ])
示例#12
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.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),
     ])
示例#13
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),
     ])
示例#14
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),
     ])
示例#15
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.REACH_TOTAL_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(31, None, 0),
         Brick(32, 20, None),
     ])
示例#16
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),
     ])
示例#17
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_AFTER_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, 5.0, None),
         Brick(20, None, 0),
         Brick(21, 20, None),
     ])
示例#18
0
 def test_idempotency(self):
     road = [
         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),
     ]
     vacay = VacationSegment(
         5, 10, 0, config_pb2.VacationPattern.REACH_TOTAL_BEFORE_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), road)
示例#19
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),
     ])
示例#20
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),
     ])
示例#21
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_BEFORE_VACATION)
     self.assertEquals(apply_vacation_segment(road, vacay), [
         Brick(0, 0, None),
         Brick(5, 10, None),
         Brick(10, None, 0),
         Brick(20, 20, None),
     ])
示例#22
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),
     ])
示例#23
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),
     ])
示例#24
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),
     ])