Ejemplo n.º 1
0
    def test_15_minute_chunks_with_45_minutes(self):

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

        chunks = [
            TimeCoachChunk(start, end) for start, end in timecoach.chunk(
                a_datetime, b_datetime, minutes=15)
        ]

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

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

        chunks = [
            TimeCoachChunk(start, end) for start, end in timecoach.chunk(
                a_datetime, b_datetime, minutes=15)
        ]

        self.assertEqual(len(chunks), 4)
        self.assertEqual(total_hours(chunks), .75)
        self._test_common(a_datetime, b_datetime, chunks)
Ejemplo n.º 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)
Ejemplo n.º 3
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)