コード例 #1
0
 def runTest(self):
     ses = Session("Test", 60*7)
     ses.add_rule("1er jour des 6",
                  freq=rrule.DAILY,
                  dtstart=datetime.date(2011, 8, 20),
                  interval=6,
                  until=datetime.date(2021, 8, 30))
     result_expected = 256620
     result = ses.total_duration
     assert result == result_expected, "bad result ? got %s instead of %s" % (result, result_expected)
コード例 #2
0
 def setUp(self):
     self.ses1 = Session("Test1", duration=60 * 8, start_hour=13, start_minute=30)
     self.ses2 = Session("Test2", duration=60 * 3, start_hour=12, start_minute=00)
     self.ses3 = Session("Test3", duration=60 * 3, start_hour=15, start_minute=00)
     self.ses4 = Session("Test4", duration=60 * 3, start_hour=20, start_minute=00)
     self.ses5 = Session("Test5", duration=60 * 3, start_hour=23, start_minute=00)
     self.ses1.add_rule("", freq=rrule.DAILY, dtstart=datetime.date(2011, 8, 20), interval=2)
     self.ses2.add_rule("", freq=rrule.DAILY, dtstart=datetime.date(2011, 8, 20), interval=2)
     self.ses3.add_rule("", freq=rrule.DAILY, dtstart=datetime.date(2011, 8, 20), interval=2)
     self.ses4.add_rule("", freq=rrule.DAILY, dtstart=datetime.date(2011, 8, 20), interval=2)
     self.ses5.add_rule("", freq=rrule.DAILY, dtstart=datetime.date(2011, 8, 20), interval=2)
コード例 #3
0
 def runTest(self):
     ses = Session("Test", 60*9)
     ses.add_rule(
         "2eme jour des 3",
         freq=rrule.DAILY,
         dtstart=datetime.date(2011, 8, 20) + relativedelta(days=+1),
         interval=3,
         until=datetime.date(2021, 8, 30))
     result_expected = 659340
     result = ses.total_duration
     assert result == result_expected, "bad result ? got %s instead of %s" % (result, result_expected)
コード例 #4
0
class TestSessionSub3(TestSession):
    def setUp(self):
        TestSession.setUp(self)
        self.ses_p2 = Session("Test2", duration=60*3,
                              start_hour=11, start_minute=30)
        self.ses_p2.add_rule(
            "Tous les jours",
            freq=rrule.DAILY,
            dtstart=datetime.date(2021, 8, 15),
            interval=1,
            until=datetime.date(2022, 6, 30))
        self.result_list = self.ses_p - self.ses_p2

    def test_1(self):
        assert datetime.datetime(2011, 8, 20, 13, 45) in self.result_list

    def test_2(self):
        assert datetime.datetime(2011, 8, 20, 11, 00) not in self.result_list

    def test_3(self):
        assert datetime.datetime(2011, 8, 20, 13, 45) in self.result_list

    def test_4(self):
        assert datetime.datetime(2011, 8, 23, 15, 00) not in self.result_list

    def test_5(self):
        assert datetime.datetime(2011, 8, 30, 12, 00) not in self.result_list

    def test_6(self):
        assert datetime.datetime(2011, 8, 30, 15, 00) not in self.result_list

    def test_7(self):
        assert datetime.datetime(2011, 9, 1, 13, 45) in self.result_list

    def test_8(self):
        assert datetime.datetime(2021, 8, 15, 15, 00) in self.result_list

    def test_9(self):
        assert datetime.datetime(2021, 8, 15, 13, 45) not in self.result_list

    def test_10(self):
        assert datetime.datetime(2021, 8, 29, 15, 00) in self.result_list

    def test_11(self):
        assert datetime.datetime(2021, 8, 29, 13, 45) not in self.result_list

    def test_12(self):
        assert datetime.datetime(2022, 6, 30, 13, 45) not in self.result_list

    def test_13(self):
        assert datetime.datetime(2022, 6, 30, 11, 00) not in self.result_list
コード例 #5
0
class TestSessionSubSpecialCases(TestSession):
    def setUp(self):
        TestSession.setUp(self)
        self.ses_p2 = Session("Test2", duration=60*3,
                              start_hour=11, start_minute=30)
        self.ses_p2.add_rule(
            "Tous les jours",
            freq=rrule.DAILY,
            dtstart=datetime.date(2021, 8, 15),
            interval=1,
            until=datetime.date(2022, 6, 30))
        self.result_list = self.ses_p + self.ses_p2

    def test_1(self):
        assert self.ses_p - None == self.ses_p

    def test_2(self):
        assert len(self.ses_p - self.ses_p) == 0
コード例 #6
0
 def setUp(self):
     TestSession.setUp(self)
     self.ses_p2 = Session("Test2", duration=60*3,
                           start_hour=11, start_minute=30)
     self.ses_p2.add_rule(
         "Tous les jours",
         freq=rrule.DAILY,
         dtstart=datetime.date(2021, 8, 15),
         interval=1,
         until=datetime.date(2022, 6, 30))
     self.result_list = self.ses_p + self.ses_p2
コード例 #7
0
class TestSessionSub5(TestSession):
    """In this test, the intervals are completely disjoints,
    so a - b == a and b - a == b
    """
    def setUp(self):
        TestSession.setUp(self)
        self.ses_p2 = Session("Test2", duration=32,
                              start_hour=11, start_minute=00)
        self.ses_p2.add_rule(
            "Tous les jours",
            freq=rrule.DAILY,
            dtstart=datetime.date(2011, 9, 15),
            interval=1,
            until=datetime.date(2011, 12, 30))
        self.result_list = self.ses_p - self.ses_p2

    def test_1(self):
        assert self.result_list == self.ses_p

    def test_2(self):
        result2 = self.ses_p2 - self.ses_p
        assert result2 == self.ses_p2
コード例 #8
0
class TestSessionSub4(TestSession):
    """In this test, the B interval is within A, so sub should result in
    spltting this results in two intervals"""
    def setUp(self):
        TestSession.setUp(self)
        self.ses_p2 = Session("Test2", duration=37,
                              start_hour=15, start_minute=30)
        self.ses_p2.add_rule(
            "Tous les jours",
            freq=rrule.DAILY,
            dtstart=datetime.date(2011, 9, 15),
            interval=1,
            until=datetime.date(2011, 12, 30))
        self.result_list = self.ses_p - self.ses_p2

    def test_1(self):
        assert datetime.datetime(2011, 9, 15, 13, 45) in self.result_list

    def test_2(self):
        assert datetime.datetime(2011, 9, 15, 15, 45) not in self.result_list

    def test_3(self):
        assert datetime.datetime(2011, 9, 15, 16, 45) in self.result_list
コード例 #9
0
 def setUp(self):
     self.ses_p = Session("Test", duration=60*8,
                          start_hour=13, start_minute=30)
     self.ses_p.add_rule("1er jour des 6",
                         freq=rrule.DAILY,
                         dtstart=datetime.date(2011, 8, 20),
                         interval=6,
                         until=datetime.date(2021, 8, 30))
     self.ses_p.add_rule(
         "2eme jour des 6",
         freq=rrule.DAILY,
         dtstart=datetime.date(2011, 8, 20) + relativedelta(days=+1),
         interval=6,
         until=datetime.date(2021, 8, 30))
     self.ses_p.add_rule(
         "3eme jour des 6",
         freq=rrule.DAILY,
         dtstart=datetime.date(2011, 8, 20) + relativedelta(days=+2),
         interval=6,
         until=datetime.date(2021, 8, 30))