def testGetEventReminders(self): e1 = Event("SYSC3101 A1", date.today()) e2 = Event("SYSC3101 A4", date.today() + timedelta(days=3)) e3 = Event("SYSC3200 Lab3", date.today() + timedelta(days=7)) self.bot.events.extend([e1, e2, e3]) expect = str(e1) + "\n" + str(e2) + "\n" self.assertEquals(expect, self.bot.getEventReminders())
def testWhatsDueAll(self): e1 = Event("SYSC3101 A1", date.today()) e2 = Event("SYSC3200 A4", date(3016, 10, 12)) e3 = Event("SYSC4001 Lab5", date.today()) self.bot.events.extend([e1, e2, e3]) expect = str(e1) + "\n" + str(e2) + "\n" + str(e3) + "\n" self.assertEquals(expect, self.bot.getUpcomingEvents("whats due?"))
def testCleanEvents(self): e1 = Event("SYSC4504 A1", date(3000, 10, 19)) e2 = Event("SYSC3101 A3", date(2010, 12, 21)) self.bot.events.append(e1) self.bot.events.append(e2) self.assertEquals(2, len(self.bot.events)) self.bot.cleanEvents() self.assertEquals(1, len(self.bot.events))
def testWhatDueThisMonth(self): e1 = Event("SYSC3200 A2", date.today() + timedelta(days=30)) e2 = Event("SYSC3101 A4", date.today() + timedelta(days=15)) e3 = Event("SYSC4805 Project", date.today() + timedelta(days=365)) self.bot.events.extend([e1, e2, e3]) expect = str(e1) + "\n" + str(e2) + "\n" self.assertEquals( expect, self.bot.getUpcomingEvents("what is due this month?"))
def testWhatDueThisWeek(self): e1 = Event("SYSC3200 Lab5", date.today()) e2 = Event("SYSC4504 A3", date.today() + timedelta(days=5)) e3 = Event("SYSC4501 A2", date.today() + timedelta(days=7)) e4 = Event("COMP1805 A4", date.today() + timedelta(days=60)) self.bot.events.extend([e1, e2, e3, e4]) expect = str(e1) + "\n" + str(e2) + "\n" + str(e3) + "\n" self.assertEquals(expect, self.bot.getUpcomingEvents("what's due this week"))
class EventTest(unittest.TestCase): def setUp(self): self.e1 = Event("SYSC4504 A1", date(3016, 10, 24), time(21)) self.e2 = Event("SYSC4602 A3", date(3016, 10, 23), time(12)) def test_to_xml(self): self.assertEqual(EVENT1_XML, self.e1.to_xml()) def test_from_xml(self): events = from_xml(TEST_EVENTS) self.assertEquals(2, len(events)) self.assertEquals(self.e1, events[0]) self.assertEquals(self.e2, events[1]) def testToStringWithTime(self): self.assertEquals(str(self.e1), "SYSC4504 A1 is due on October 24 3016 at 09:00PM") def testToStringWithoutTime(self): e = Event("SYSC3101 A2", date(3016, 12, 10)) self.assertEquals(str(e), "SYSC3101 A2 is due on December 10 3016") def testYearSet(self): e1 = Event("Event 1", date(1900, date.today().month, 12)) e2 = Event("Event 2", date(1900, date.today().month - 1, 12)) today = date.today() self.assertEquals(today.year, e1.dueDate.year) self.assertEquals(today.year + 1, e2.dueDate.year)
def testYearSet(self): e1 = Event("Event 1", date(1900, date.today().month, 12)) e2 = Event("Event 2", date(1900, date.today().month - 1, 12)) today = date.today() self.assertEquals(today.year, e1.dueDate.year) self.assertEquals(today.year + 1, e2.dueDate.year)
def testToStringWithoutTime(self): e = Event("SYSC3101 A2", date(3016, 12, 10)) self.assertEquals(str(e), "SYSC3101 A2 is due on December 10 3016")
def setUp(self): self.e1 = Event("SYSC4504 A1", date(3016, 10, 24), time(21)) self.e2 = Event("SYSC4602 A3", date(3016, 10, 23), time(12))
def testCreateEventWithTime(self): e = Event("SYSC2300 A2", date(3016, 12, 14), time(9)) self.bot.parseInstruction("SYSC2300 A2 is due December 14 3016 at 9AM") self.assertEquals(e, self.bot.events[0])
def testCreateEventShortFormDate1(self): e = Event("SYSC4504 A1", date(3016, 1, 12)) self.bot.parseInstruction("SYSC4504 A1 is due on 12/01/3016") self.assertEquals(e, self.bot.events[0])
def testCreateEventLongFormDate2(self): e = Event("SYSC3101 Assignment 2 Flex/Bison", date(3015, 10, 31)) self.bot.parseInstruction( "SYSC3101 Assignment 2 Flex/Bison due October 31 3015") self.assertEquals(e, self.bot.events[0])
def testCreateEventLongFormDate1(self): e = Event("SYSC4504 A1", date(3012, 12, 12)) self.bot.parseInstruction("SYSC4504 A1 is due on December 12 3012") self.assertEqual(e, self.bot.events[0])