예제 #1
0
 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)))
예제 #2
0
 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())))
예제 #3
0
    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)
예제 #4
0
    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")
예제 #5
0
    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")
예제 #6
0
 def tearDown(self):
     TimeRange.removeAll()
     Time.removeAll()
예제 #7
0
 def setUp(self):
     TimeRanges.removeAll()
     TimeRange.removeAll()
     Time.removeAll()
예제 #8
0
def makeCSE403TimeRange():
    t = Time.getInstance(EnumWeekday.MONDAY, 10, 30)
    return TimeRange.getInstance(t, 50)
예제 #9
0
 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())))
예제 #10
0
 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)))
예제 #11
0
 def tearDown(self):
     TimeRange.removeAll()
     Time.removeAll()