def testGetInstanceInDatabaseMon1030Duration50(self): t = getTime(1, 10, 30) # monday 10 30 durationX = 50 TimeRange.getInstance(t, durationX) L = TimeRange.objects.filter(timeID=t.id, duration=durationX) self.assertTrue( len(L) == 1, myMsg("database existance test", "exist", str(len(L) == 1)))
def testGetEndTime(self): t = getTime(1, 10, 30) durationX = 50 tr = TimeRange.getInstance(t, durationX) tend = getTime(1, 11, 20) self.assertEqual( tend, tr.getEndTime(), myMsg("testing get end time", str(tend), str(tr.getEndTime())))
def testAddTimeEndAndStartAtTheSameTime(self): t2 = Time.getInstance(EnumWeekday.MONDAY, 9, 30) tr2 = TimeRange.getInstance(t2, 60) tr = makeCSE403TimeRange() trs = TimeRanges.getInstance() trs.addTimeRange(tr) trs.addTimeRange(tr2)
def testGetAll(self): tr = makeCSE403TimeRange() t2 = Time.getInstance(EnumWeekday.MONDAY, 9, 30) tr2 = TimeRange.getInstance(t2, 60) t3 = Time.getInstance(EnumWeekday.MONDAY, 8, 30) tr3 = TimeRange.getInstance(t3, 60) trs = TimeRanges.getInstance() trs.addTimeRange(tr) trs.addTimeRange(tr2) trs.addTimeRange(tr3) allTRs = trs.getAll() self.assertTrue(tr in allTRs, str(tr) + " not in trs when getall is called") self.assertTrue(tr2 in allTRs, str(tr2) + " not in trs when getall is called") self.assertTrue(tr3 in allTRs, str(tr3) + " not in trs when getall is called")
def testAdd1Add2Remove1And2Exist(self): tr = makeCSE403TimeRange() t2 = Time.getInstance(EnumWeekday.MONDAY, 9, 30) tr2 = TimeRange.getInstance(t2, 60) trs = TimeRanges.getInstance() trs.addTimeRange(tr) trs.addTimeRange(tr2) trs.removeTimeRange(tr) self.assertTrue(trs.containTime(tr2), "tr2 should be in trs but got removed")
def tearDown(self): TimeRange.removeAll() Time.removeAll()
def setUp(self): TimeRanges.removeAll() TimeRange.removeAll() Time.removeAll()
def makeCSE403TimeRange(): t = Time.getInstance(EnumWeekday.MONDAY, 10, 30) return TimeRange.getInstance(t, 50)
def testGetEndTime(self): t = getTime(1,10,30) durationX = 50 tr = TimeRange.getInstance(t, durationX) tend = getTime(1,11,20) self.assertEqual(tend, tr.getEndTime(), myMsg("testing get end time", str(tend), str(tr.getEndTime())))
def testGetInstanceInDatabaseMon1030Duration50(self): t = getTime(1,10,30) # monday 10 30 durationX = 50 TimeRange.getInstance(t, durationX) L = TimeRange.objects.filter(timeID=t.id, duration=durationX) self.assertTrue(len(L) == 1, myMsg("database existance test", "exist", str(len(L) == 1)))