예제 #1
0
 def setUp(self):
     small = """
     2018-01-01 09:15 10:30 | drowsy
     2018-01-01 10:15 11:20 | coffee
     2018-01-01 11:30 12:00 | waking
     """
     small_conflicts = """
     2018-01-01 10:15 10:30 |  drowsy & coffee
     """
     self.small = parse_agenda(small)
     self.small_conflicts = parse_agenda(small_conflicts)
     big = open("test_data/thousand.txt")
     self.big = read_agenda(big)
     big.close()
예제 #2
0
 def test_2_conflicts(self):
     """Like thousand.txt but with a couple of conflicts"""
     expected_txt = """
     2018-12-02 02:30 02:59 |   oops
     2018-12-02 03:00 03:59 |   oops  
     2018-12-02 04:00 04:59 |   oops
     2018-12-02 05:00 05:30 |   oops
     2018-12-07 06:30 06:59 |   oops
     2018-12-07 07:00 07:30 |   oops
     """
     expected_conflicts = parse_agenda(expected_txt)
     expected_conflicts.sort()
     oopsy_file = open("test_data/thousand2.txt")
     agenda = read_agenda(oopsy_file)
     oopsy_file.close()
     time_before = time.perf_counter()
     oops = agenda.conflicts()
     time_after = time.perf_counter()
     elapsed_seconds = time_after - time_before
     self.assertLess(elapsed_seconds, 3,
                     "Are you sure your algorithm is linear time?")
     log.debug(
         f"Checked {len(agenda)} entries in {elapsed_seconds} seconds")
     oops.sort()
     self.assertEqual(oops, expected_conflicts)
예제 #3
0
 def test02_sorting(self):
     ag = parse_agenda(self.unsorted)
     ag.sort()
     out = str(ag)
     show_diff(out, self.example)
     self.assertEqual(crush(self.example), crush(out))
예제 #4
0
 def test01_inout(self):
     ag = parse_agenda(self.example)
     out = str(ag)
     show_diff(out, self.example)
     self.assertEqual(crush(self.example), crush(out))