예제 #1
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_give_total_time_for_month(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(4, TimeRange(Time(7), Time(17, 10)))
     m.add_week(40, w)
     m.add_week(42, w)
     self.assertEquals(m.get_total_time(), Hours(20, 20))
예제 #2
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_return_week(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     m.add_week(40, w)
     self.assertEquals(
         m.get_week(40).get_day(0), TimeRange(Time(7), Time(17)))
예제 #3
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_enter_times_into_first_incomplete_week(self):
     m = Month(2012, 11)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     w.set_day(3, TimeRange(Time(8), Time(18)))
     m.add_week(44, w)
     self.assertEquals(m.get_day(1), TimeRange(Time(8), Time(18)))
예제 #4
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_give_total_time_for_month(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(4, TimeRange(Time(7), Time(17, 10)))
     m.add_week(40, w)
     m.add_week(42, w)
     self.assertEquals(m.get_total_time(), Hours(20, 20))
예제 #5
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_enter_times_into_first_incomplete_week(self):
     m = Month(2012, 11)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     w.set_day(3, TimeRange(Time(8), Time(18)))
     m.add_week(44, w)
     self.assertEquals(m.get_day(1), TimeRange(Time(8), Time(18)))
예제 #6
0
파일: MonthTest.py 프로젝트: remar/bfiller
    def test_can_return_half_week(self):
        m = Month(2012, 11)
        w = Week()
        w.set_day(2, TimeRange(Time(7), Time(17)))
        w.set_day(3, TimeRange(Time(8), Time(18)))
        m.add_week(44, w)

        self.assertEquals(m.get_week(44).get_day(2), None)
예제 #7
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_enter_times_from_last_week_in_month(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(2, TimeRange(Time(7), Time(17)))
     w.set_day(3, TimeRange(Time(7), Time(17)))
     m.add_week(44, w)
     self.assertEquals(m.get_day(31), TimeRange(Time(7), Time(17)))
     self.assertNotEquals(m.get_day(32), TimeRange(Time(7), Time(17)))
예제 #8
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_enter_times_from_last_week_in_month(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(2, TimeRange(Time(7), Time(17)))
     w.set_day(3, TimeRange(Time(7), Time(17)))
     m.add_week(44, w)
     self.assertEquals(m.get_day(31), TimeRange(Time(7), Time(17)))
     self.assertNotEquals(m.get_day(32), TimeRange(Time(7), Time(17)))
예제 #9
0
파일: MonthTest.py 프로젝트: remar/bfiller
    def test_can_return_half_week(self):
        m = Month(2012, 11)
        w = Week()
        w.set_day(2, TimeRange(Time(7), Time(17)))
        w.set_day(3, TimeRange(Time(8), Time(18)))
        m.add_week(44, w)

        self.assertEquals(m.get_week(44).get_day(2), None)
예제 #10
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_doesnt_schedule_hours_scheduled_by_taken_week(self):
        y = Year(2012)
        taken = Week()
        taken.set_day(0, TimeRange(Time(13, 30), Time(17)))
        y.add_taken(40, taken)

        w = y.get_schedule_for_week(40, Hours(47, 50))

        self.assertEquals(w.get_total_time(), Hours(44, 20))
예제 #11
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_uses_blocked_week_when_scheduling(self):
        y = Year(2012)
        blocked = Week()
        blocked.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
        y.add_blocked(40, blocked)

        w = y.get_schedule_for_week(40, Hours(57, 50))

        self.assertEquals(w.get_day(0).get_start(), Time(13, 30))
예제 #12
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_uses_blocked_week_when_scheduling(self):
        y = Year(2012)
        blocked = Week()
        blocked.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
        y.add_blocked(40, blocked)

        w = y.get_schedule_for_week(40, Hours(57, 50))

        self.assertEquals(w.get_day(0).get_start(), Time(13, 30))
예제 #13
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_uses_taken_week_when_scheduling(self):
        y = Year(2012)
        taken = Week()
        taken.set_day(0, TimeRange(Time(13, 30), Time(17)))
        y.add_taken(40, taken)

        w = y.get_schedule_for_week(40, Hours(57, 50))

        self.assertEquals(w.get_day(0).get_start(), Time(17))
예제 #14
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_uses_taken_week_when_scheduling(self):
        y = Year(2012)
        taken = Week()
        taken.set_day(0, TimeRange(Time(13, 30), Time(17)))
        y.add_taken(40, taken)

        w = y.get_schedule_for_week(40, Hours(57, 50))

        self.assertEquals(w.get_day(0).get_start(), Time(17))
예제 #15
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_doesnt_schedule_hours_scheduled_by_taken_week(self):
        y = Year(2012)
        taken = Week()
        taken.set_day(0, TimeRange(Time(13, 30), Time(17)))
        y.add_taken(40, taken)

        w = y.get_schedule_for_week(40, Hours(47, 50))

        self.assertEquals(w.get_total_time(), Hours(44, 20))
예제 #16
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_returns_correctly_annotated_week_for_start_of_month(self):
     m = Month(2012, 11)
     w = Week()
     for i in xrange(7):
         w.set_day(i, TimeRange(Time(7), Time(17)))
     m.add_week(44, w)
     aw = m.get_week(44)
     self.assertEquals(aw.get_earliest_day_in_month(), 1)
     self.assertEquals(aw.get_first_valid_day(), 3)
     self.assertEquals(aw.get_last_valid_day(), 6)
예제 #17
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_returns_correctly_annotated_week_for_start_of_month(self):
     m = Month(2012, 11)
     w = Week()
     for i in xrange(7):
         w.set_day(i, TimeRange(Time(7), Time(17)))
     m.add_week(44, w)
     aw = m.get_week(44)
     self.assertEquals(aw.get_earliest_day_in_month(), 1)
     self.assertEquals(aw.get_first_valid_day(), 3)
     self.assertEquals(aw.get_last_valid_day(), 6)
예제 #18
0
파일: WeekTest.py 프로젝트: remar/bfiller
    def test_can_be_printed(self):
        w = Week()
        for i in xrange(7):
            w.set_day(i, TimeRange(Time(7), Time(17)))
        self.assertEquals(str(w), """M: 7:00-17:00
T: 7:00-17:00
O: 7:00-17:00
T: 7:00-17:00
F: 7:00-17:00
L: 7:00-17:00
S: 7:00-17:00""")
예제 #19
0
 def test_first_day_is_shorter_if_day_is_taken(self):
     taken_week = Week()
     taken_week.set_day(0, TimeRange(Time(7), Time(17)))
     week = generate_week(Hours(40), taken_week)
     ranges = [TimeRange(Time(17), Time(20)),
               TimeRange(Time(7), Time(17)),
               TimeRange(Time(7), Time(17)),
               TimeRange(Time(7), Time(17)),
               TimeRange(Time(7), Time(14))]
     for i in xrange(5):
         self.assertEquals(week.get_day(i), ranges[i])
예제 #20
0
파일: WeekTest.py 프로젝트: remar/bfiller
    def test_can_be_printed(self):
        w = Week()
        for i in xrange(7):
            w.set_day(i, TimeRange(Time(7), Time(17)))
        self.assertEquals(
            str(w), """M: 7:00-17:00
T: 7:00-17:00
O: 7:00-17:00
T: 7:00-17:00
F: 7:00-17:00
L: 7:00-17:00
S: 7:00-17:00""")
예제 #21
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_respects_both_blocked_and_taken_weeks(self):
        y = Year(2012)
        blocked = Week()
        blocked.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
        y.add_blocked(40, blocked)
        taken = Week()
        taken.set_day(1, TimeRange(Time(7), Time(17)))
        y.add_taken(40, taken)

        w = y.get_schedule_for_week(40, Hours(57, 50))

        self.assertEquals(w.get_day(0).get_start(), Time(13, 30))
        self.assertEquals(w.get_day(1).get_start(), Time(17))
예제 #22
0
파일: YearTest.py 프로젝트: remar/bfiller
    def test_respects_both_blocked_and_taken_weeks(self):
        y = Year(2012)
        blocked = Week()
        blocked.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
        y.add_blocked(40, blocked)
        taken = Week()
        taken.set_day(1, TimeRange(Time(7), Time(17)))
        y.add_taken(40, taken)

        w = y.get_schedule_for_week(40, Hours(57, 50))

        self.assertEquals(w.get_day(0).get_start(), Time(13, 30))
        self.assertEquals(w.get_day(1).get_start(), Time(17))
예제 #23
0
 def test_first_day_is_shorter_if_day_is_taken(self):
     taken_week = Week()
     taken_week.set_day(0, TimeRange(Time(7), Time(17)))
     week = generate_week(Hours(40), taken_week)
     ranges = [
         TimeRange(Time(17), Time(20)),
         TimeRange(Time(7), Time(17)),
         TimeRange(Time(7), Time(17)),
         TimeRange(Time(7), Time(17)),
         TimeRange(Time(7), Time(14))
     ]
     for i in xrange(5):
         self.assertEquals(week.get_day(i), ranges[i])
예제 #24
0
파일: YearTest.py 프로젝트: remar/bfiller
 def _get_assistance_week(self):
     w = Week()
     w.set_day(0, TimeRange(Time(13, 30), Time(17)))
     w.set_day(1, TimeRange(Time(6, 30), Time(8, 30)))
     w.set_day(2, TimeRange(Time(7), Time(17)))
     w.set_day(3, TimeRange(Time(6, 30), Time(8, 30)))
     return w
예제 #25
0
파일: YearTest.py 프로젝트: remar/bfiller
 def _get_assistance_week(self):
     w = Week()
     w.set_day(0, TimeRange(Time(13, 30), Time(17)))
     w.set_day(1, TimeRange(Time(6, 30), Time(8, 30)))
     w.set_day(2, TimeRange(Time(7), Time(17)))
     w.set_day(3, TimeRange(Time(6, 30), Time(8, 30)))
     return w
예제 #26
0
    def test_generates_realistic_schedule(self):
        taken_week = Week()
        taken = [TimeRange(Time(8, 30), Time(13, 30)),
                 TimeRange(Time(6, 30), Time(13, 30)),
                 TimeRange(Time(7), Time(17)),
                 TimeRange(Time(6, 30), Time(13, 30))]
        for i in xrange(len(taken)):
            taken_week.set_day(i, taken[i])

        week = generate_week(Hours(30, 20), taken_week)

        ranges = [TimeRange(Time(13, 30), Time(20)), # 23:50 left
                  TimeRange(Time(13, 30), Time(20)), # 17:20 left
                  TimeRange(Time(17), Time(20)), # 14:20 left
                  TimeRange(Time(13, 30), Time(20)), # 7:50 left
                  TimeRange(Time(7), Time(14, 50))] # 0:00 left
        for i in xrange(len(ranges)):
            self.assertEquals(week.get_day(i), ranges[i])
예제 #27
0
def generate_week(hours, taken_week=None, latest_time=None):
    latest_time = latest_time or DEFAULT_LATEST_TIME
    longest_day = DEFAULT_LONGEST_DAY

    week = Week()
    day = 0
    while hours > Hours(0):
        assert (day < 7)
        taken_hours = taken_week.get_day(day) if taken_week != None else None
        generated_day = generate_day(
            longest_day if hours > longest_day else hours, taken_hours,
            latest_time)
        if generated_day.get_length().get_total_minutes() > 0:
            week.set_day(day, generated_day)
        day += 1
        hours -= generated_day.get_length()

    return week
예제 #28
0
def generate_week(hours, taken_week = None, latest_time = None):
    latest_time = latest_time or DEFAULT_LATEST_TIME
    longest_day = DEFAULT_LONGEST_DAY

    week = Week()
    day = 0
    while hours > Hours(0):
        assert(day < 7)
        taken_hours = taken_week.get_day(day) if taken_week != None else None
        generated_day = generate_day(longest_day if hours > longest_day else hours,
                                     taken_hours,
                                     latest_time)
        if generated_day.get_length().get_total_minutes() > 0:
            week.set_day(day, generated_day)
        day += 1
        hours -= generated_day.get_length()

    return week
예제 #29
0
파일: WeekTest.py 프로젝트: remar/bfiller
    def test_can_be_concatenated(self):
        w1 = Week()
        w2 = Week()
        w1.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
        w2.set_day(0, TimeRange(Time(13, 30), Time(17)))

        w1.set_day(1, TimeRange(Time(7), Time(12)))

        w2.set_day(2, TimeRange(Time(8), Time(13)))

        w3 = w1 + w2
        self.assertEquals(w3.get_day(0), TimeRange(Time(8, 30), Time(17)))
        self.assertEquals(w3.get_day(1), TimeRange(Time(7), Time(12)))
        self.assertEquals(w3.get_day(2), TimeRange(Time(8), Time(13)))
예제 #30
0
파일: WeekTest.py 프로젝트: remar/bfiller
    def test_can_be_concatenated(self):
        w1 = Week()
        w2 = Week()
        w1.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
        w2.set_day(0, TimeRange(Time(13, 30), Time(17)))

        w1.set_day(1, TimeRange(Time(7), Time(12)))

        w2.set_day(2, TimeRange(Time(8), Time(13)))

        w3 = w1 + w2
        self.assertEquals(w3.get_day(0), TimeRange(Time(8, 30), Time(17)))
        self.assertEquals(w3.get_day(1), TimeRange(Time(7), Time(12)))
        self.assertEquals(w3.get_day(2), TimeRange(Time(8), Time(13)))
예제 #31
0
    def test_generates_realistic_schedule(self):
        taken_week = Week()
        taken = [
            TimeRange(Time(8, 30), Time(13, 30)),
            TimeRange(Time(6, 30), Time(13, 30)),
            TimeRange(Time(7), Time(17)),
            TimeRange(Time(6, 30), Time(13, 30))
        ]
        for i in xrange(len(taken)):
            taken_week.set_day(i, taken[i])

        week = generate_week(Hours(30, 20), taken_week)

        ranges = [
            TimeRange(Time(13, 30), Time(20)),  # 23:50 left
            TimeRange(Time(13, 30), Time(20)),  # 17:20 left
            TimeRange(Time(17), Time(20)),  # 14:20 left
            TimeRange(Time(13, 30), Time(20)),  # 7:50 left
            TimeRange(Time(7), Time(14, 50))
        ]  # 0:00 left
        for i in xrange(len(ranges)):
            self.assertEquals(week.get_day(i), ranges[i])
예제 #32
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_add_week_52_of_previous_year_to_january(self):
     m = Month(2012, 1)
     w = Week()
     w.set_day(6, TimeRange(Time(7), Time(10)))
     m.add_week(52, w)
     self.assertEquals(m.get_day(1), TimeRange(Time(7), Time(10)))
예제 #33
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_add_week_1_of_next_year_to_december(self):
     m = Month(2012, 12)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(10)))
     m.add_week(1, w)
     self.assertEquals(m.get_day(31), TimeRange(Time(7), Time(10)))
예제 #34
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_add_week_1_of_next_year_to_december(self):
     m = Month(2012, 12)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(10)))
     m.add_week(1, w)
     self.assertEquals(m.get_day(31), TimeRange(Time(7), Time(10)))
예제 #35
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_add_week_52_of_previous_year_to_january(self):
     m = Month(2012, 1)
     w = Week()
     w.set_day(6, TimeRange(Time(7), Time(10)))
     m.add_week(52, w)
     self.assertEquals(m.get_day(1), TimeRange(Time(7), Time(10)))
예제 #36
0
파일: WeekTest.py 프로젝트: remar/bfiller
    def test_can_report_total_hours_and_minutes(self):
        w = Week()
        w.set_day(0, TimeRange(Time(7), Time(17)))
        w.set_day(1, TimeRange(Time(10), Time(10, 30)))

        self.assertEquals(w.get_total_time(), Hours(10, 30))
예제 #37
0
 def test_can_be_modified_with_latest_time(self):
     taken_week = Week()
     taken_week.set_day(0, TimeRange(Time(7), Time(17)))
     week = generate_week(Hours(40), taken_week, Time(22))
     self.assertEquals(week.get_day(0), TimeRange(Time(17), Time(22)))
예제 #38
0
 def test_can_be_modified_with_latest_time(self):
     taken_week = Week()
     taken_week.set_day(0, TimeRange(Time(7), Time(17)))
     week = generate_week(Hours(40), taken_week, Time(22))
     self.assertEquals(week.get_day(0), TimeRange(Time(17), Time(22)))
예제 #39
0
파일: YearTest.py 프로젝트: remar/bfiller
 def _get_daycare_week(self):
     w = Week()
     w.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
     w.set_day(1, TimeRange(Time(8, 30), Time(13, 30)))
     w.set_day(3, TimeRange(Time(8, 30), Time(13, 30)))
     return w
예제 #40
0
파일: YearTest.py 프로젝트: remar/bfiller
 def _get_daycare_week(self):
     w = Week()
     w.set_day(0, TimeRange(Time(8, 30), Time(13, 30)))
     w.set_day(1, TimeRange(Time(8, 30), Time(13, 30)))
     w.set_day(3, TimeRange(Time(8, 30), Time(13, 30)))
     return w
예제 #41
0
파일: WeekTest.py 프로젝트: remar/bfiller
    def test_can_report_total_hours_and_minutes(self):
        w = Week()
        w.set_day(0, TimeRange(Time(7), Time(17)))
        w.set_day(1, TimeRange(Time(10), Time(10, 30)))

        self.assertEquals(w.get_total_time(), Hours(10, 30))
예제 #42
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_enter_times_from_second_week(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     m.add_week(41, w)
     self.assertEquals(m.get_day(8), TimeRange(Time(7), Time(17)))
예제 #43
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_return_week(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     m.add_week(40, w)
     self.assertEquals(m.get_week(40).get_day(0), TimeRange(Time(7), Time(17)))
예제 #44
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_returns_annotated_weeks(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     m.add_week(40, w)
     self.assertEquals(type(m.get_week(40)), AnnotatedWeek)
예제 #45
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_returns_annotated_weeks(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     m.add_week(40, w)
     self.assertEquals(type(m.get_week(40)), AnnotatedWeek)
예제 #46
0
파일: MonthTest.py 프로젝트: remar/bfiller
 def test_can_enter_times_from_second_week(self):
     m = Month(2012, 10)
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     m.add_week(41, w)
     self.assertEquals(m.get_day(8), TimeRange(Time(7), Time(17)))
예제 #47
0
파일: WeekTest.py 프로젝트: remar/bfiller
 def test_can_set_day(self):
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     self.assertEquals(w.get_day(0), TimeRange(Time(7), Time(17)))
예제 #48
0
파일: WeekTest.py 프로젝트: remar/bfiller
 def test_can_set_day(self):
     w = Week()
     w.set_day(0, TimeRange(Time(7), Time(17)))
     self.assertEquals(w.get_day(0), TimeRange(Time(7), Time(17)))