示例#1
0
    def test_add_day_if_datetime_is_in_past(self):
        dt_now = datetime.now()
        dt = dt_now - timedelta(minutes=1)
        dt = add_day_if_past(dt)
        assert dt.day > dt_now.day

        dt = dt_now + timedelta(hours=1)
        dt = add_day_if_past(dt)
        assert dt.day == dt_now.day
示例#2
0
    def test_add_day_if_datetime_is_in_past(self):
        dt_now = datetime(2020, 1, 1, 9, 0)
        todocli.datetime_parser.datetime.now.return_value = dt_now
        dt = dt_now - timedelta(minutes=1)
        dt = add_day_if_past(dt)
        self.assertGreater(dt.day, dt_now.day)

        dt = dt_now + timedelta(hours=1)
        dt = add_day_if_past(dt)
        self.assertEqual(dt.day, dt_now.day)
示例#3
0
 def test_am_pm_time3(self):
     input_str = "12:00 am"
     dt = parse_datetime(input_str)
     dt_expected = datetime.now().replace(hour=0,
                                          minute=0,
                                          second=0,
                                          microsecond=0)
     dt_expected = add_day_if_past(dt_expected)
     assert dt == dt_expected
示例#4
0
 def test_am_pm_time2(self):
     input_str = "7:00 pm"
     dt = parse_datetime(input_str)
     dt_expected = datetime.now().replace(hour=19, minute=0, second=0, microsecond=0)
     dt_expected = add_day_if_past(dt_expected)
     self.assertEqual(dt, dt_expected)