Beispiel #1
0
    def test_get_time_of_day(self):
        date_time_morning = kronos.get_date_time_from_string(
            "2020-07-19 08:14:21")
        self.assertEqual("morning", kronos.get_time_of_day(date_time_morning))

        date_time_afternoon = kronos.get_date_time_from_string(
            "2020-07-19 12:14:21")
        self.assertEqual("afternoon",
                         kronos.get_time_of_day(date_time_afternoon))

        date_time_evening = kronos.get_date_time_from_string(
            "2020-07-19 20:14:21")
        self.assertEqual("evening", kronos.get_time_of_day(date_time_evening))
Beispiel #2
0
 def test_get_day_of_week(self):
     for i in range(len(kronos.week_days)):
         date = kronos.get_date_time_from_string(
             f"2020-08-{10 + i} 13:00:00")
         self.assertEqual(kronos.week_days.get(i),
                          kronos.get_day_of_week(date))
Beispiel #3
0
 def test_is_previous_friday(self):
     last_friday = "2020-08-14 13:00:00"
     last_monday = kronos.get_date_time_from_string("2020-08-17 13:00:00")
     self.assertTrue(kronos.is_previous_friday(last_friday, last_monday))
     last_tuesday = kronos.get_date_time_from_string("2020-08-18 13:00:00")
     self.assertFalse(kronos.is_previous_friday(last_friday, last_tuesday))
Beispiel #4
0
 def test_is_yesterday(self):
     date_time = kronos.get_date_time_from_string("2020-07-20 18:14:21")
     self.assertTrue(kronos.is_yesterday(date_time_str, today=date_time))
     date_time = kronos.get_date_time_from_string("2020-07-19 18:14:21")
     self.assertFalse(kronos.is_yesterday(date_time_str, today=date_time))