Exemple #1
0
    def test_week(self):

        a_datetime = dateparser.parse('1-1-90 11:15:00')
        b_datetime = a_datetime + timedelta(days=7)

        chunks = list(iter_chunks(a_datetime, b_datetime,
                                  timecoach.chunk_days))

        self.assertEqual(len(chunks), 8)
        self.assertEqual(chunks[4].diff.days, 1)
Exemple #2
0
    def test_hour_leap(self):

        a_datetime = dateparser.parse('1-1-90 11:15:00')
        b_datetime = a_datetime + timedelta(hours=1)

        chunks = list(
            iter_chunks(a_datetime, b_datetime, timecoach.chunk_hours))

        self.assertEqual(len(chunks), 2)
        self.assertEqual(total_hours(chunks), 1)
        self._test_common(a_datetime, b_datetime, chunks)
Exemple #3
0
    def test_half_year(self):

        a_datetime = dateparser.parse('1-15-90 12:00:00')
        b_datetime = a_datetime + timedelta(days=6 * 30)

        chunks = list(
            iter_chunks(a_datetime, b_datetime, timecoach.chunk_months))
        self.assertEqual(len(chunks), 7)
        self.assertEqual(chunks[0].diff.days, 16)
        self.assertEqual(chunks[0].diff.seconds, 12 * 3600)
        self.assertEqual(chunks[2].diff.days, 31)  # 31 days in May
Exemple #4
0
    def test_hour_and_half_leap(self):

        a_datetime = dateparser.parse('1-1-90 11:45:00')
        b_datetime = a_datetime + timedelta(hours=1, minutes=30)

        chunks = list(
            iter_chunks(a_datetime, b_datetime, timecoach.chunk_hours))

        self.assertEqual(len(chunks), 3)
        self.assertEqual(total_hours(chunks), 1.5)
        self._test_common(a_datetime, b_datetime, chunks)