def test_parse_correction_ignores_bad_relative_times(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("-200 did stuff"), ("-200 did stuff", None))
def test_parse_correction_recognizes_relative_times(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("-20 did stuff"), ("did stuff", datetime.datetime(2015, 5, 12, 16, 7)))
def test_parse_correction_ignores_relative_times_before_last_entry(self): timelog = TimeLog(StringIO("2015-05-12 16:00: stuff"), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("-30 did stuff"), ("-30 did stuff", None))
def test_parse_correction_handles_virtual_midnight_todays_time(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("00:15 did stuff"), ("did stuff", datetime.datetime(2015, 5, 13, 00, 15)))
def test_parse_correction_ignores_bad_absolute_times(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("19:60 did stuff"), ("19:60 did stuff", None)) self.assertEqual(timelog.parse_correction("24:00 did stuff"), ("24:00 did stuff", None))
def test_parse_correction_leaves_regular_text_alone(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("did stuff"), ("did stuff", None))
def test_parse_correction_handles_virtual_midnight_yesterdays_time(self): # Regression test for https://github.com/gtimelog/gtimelog/issues/33 timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("15:20 did stuff"), ("did stuff", datetime.datetime(2015, 5, 12, 15, 20)))
def test_parse_correction_ignores_relative_times_before_last_entry(self): timelog = TimeLog(StringIO("2015-05-12 16:00: stuff"), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("-30 did stuff"), ("-30 did stuff", None))
def test_parse_correction_ignores_bad_relative_times(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("-200 did stuff"), ("-200 did stuff", None))
def test_parse_correction_recognizes_relative_times(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("-20 did stuff"), ("did stuff", datetime.datetime(2015, 5, 12, 16, 7)))
def test_parse_correction_ignores_bad_absolute_times(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("19:60 did stuff"), ("19:60 did stuff", None)) self.assertEqual(timelog.parse_correction("24:00 did stuff"), ("24:00 did stuff", None))
def test_parse_correction_handles_virtual_midnight_todays_time(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("00:15 did stuff"), ("did stuff", datetime.datetime(2015, 5, 13, 00, 15)))
def test_parse_correction_handles_virtual_midnight_yesterdays_time(self): # Regression test for https://github.com/gtimelog/gtimelog/issues/33 timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("15:20 did stuff"), ("did stuff", datetime.datetime(2015, 5, 12, 15, 20)))
def test_parse_correction_leaves_regular_text_alone(self): timelog = TimeLog(StringIO(), datetime.time(2, 0)) self.assertEqual(timelog.parse_correction("did stuff"), ("did stuff", None))