Exemplo n.º 1
0
 def testShiftSUN2330by60min(self):
     t2330 = Time.getInstance(EnumWeekday.SUNDAY, 23, 30)
     tShift = t2330.shift(60)
     tReal = Time.getInstance(EnumWeekday.MONDAY, 00, 30)
     self.assertEqual(
         tReal, tShift,
         myMsg("test sunday to monday shift", str(tReal), str(tShift)))
Exemplo n.º 2
0
 def testShiftMon1230by30min(self):
     t1230 = makeMon1230()
     t1300_shifted = t1230.shift(30)
     t1300_real = Time.getInstance(EnumWeekday.MONDAY, 13, 00)
     self.assertEqual(
         t1300_real, t1300_shifted,
         myMsg("test shift", str(t1300_real), str(t1300_shifted)))
Exemplo n.º 3
0
    def testConstructorNormalCase(self):
        mon = EnumWeekday.MONDAY
        hour = 12
        mini = 30
        t = Time.getInstance(mon, hour, mini)

        self.assertEqual(mon, t.getWeekday(), "Weekday: Expect " + str(mon) + " but receive " + str(t.getWeekday()))
        self.assertEqual(hour, t.getHour(), "Hour: Expect " + str(hour) + " but receive " + str(t.getHour()))
        self.assertEqual(mini, t.getMini(), "Miniute: Expect " + str(mini) + " but receive " + str(t.getMini()))
Exemplo n.º 4
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)
Exemplo n.º 5
0
 def testDataBaseHasElement(self):
     mon = EnumWeekday.MONDAY
     hour = 12
     mini = 30
     myTime = datetime.time(12,30)
     
     # no object in database
     L = Time.objects.filter(time=myTime, dayIndex=mon())
     # add object in database
     t = Time.getInstance(mon, hour, mini)
     self.assertTrue(1 == len(L), myMsg("Test Time Exist in Database", '1', str(len(L))))
Exemplo n.º 6
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")
Exemplo n.º 7
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")
Exemplo n.º 8
0
    def testDataBaseHasElement(self):
        mon = EnumWeekday.MONDAY
        hour = 12
        mini = 30
        myTime = datetime.time(12, 30)

        # no object in database
        L = Time.objects.filter(time=myTime, dayIndex=mon())
        # add object in database
        t = Time.getInstance(mon, hour, mini)
        self.assertTrue(1 == len(L),
                        myMsg("Test Time Exist in Database", '1', str(len(L))))
Exemplo n.º 9
0
    def testConstructorNormalCase(self):
        mon = EnumWeekday.MONDAY
        hour = 12
        mini = 30
        t = Time.getInstance(mon, hour, mini)

        self.assertEqual(
            mon, t.getWeekday(), "Weekday: Expect " + str(mon) +
            " but receive " + str(t.getWeekday()))
        self.assertEqual(
            hour, t.getHour(),
            "Hour: Expect " + str(hour) + " but receive " + str(t.getHour()))
        self.assertEqual(
            mini, t.getMini(), "Miniute: Expect " + str(mini) +
            " but receive " + str(t.getMini()))
Exemplo n.º 10
0
def makeMon1230():
    mon = EnumWeekday.MONDAY
    hour = 12
    mini = 30
    myTime = datetime.time(12, 30)
    return Time.getInstance(mon, hour, mini)
Exemplo n.º 11
0
def makeMon1230():
    mon = EnumWeekday.MONDAY
    hour = 12
    mini = 30
    myTime = datetime.time(12,30)
    return Time.getInstance(mon, hour, mini)
Exemplo n.º 12
0
 def testSameDay1230MoreThan1200(self):
     t1 = makeMon1230()
     t2 = Time.getInstance(EnumWeekday.MONDAY, 12, 00)
     self.assertTrue(t1 > t2, myMsg("test same day compare", "12:30 > 12:00",  str(t1 > t2)))
Exemplo n.º 13
0
def makeCSE403TimeRange():
    t = Time.getInstance(EnumWeekday.MONDAY, 10, 30)
    return TimeRange.getInstance(t, 50)
Exemplo n.º 14
0
 def tearDown(self):
     TimeRange.removeAll()
     Time.removeAll()
Exemplo n.º 15
0
 def testShiftMon2330by30min(self):
     t2330 = Time.getInstance(EnumWeekday.MONDAY, 23, 30)
     tShift = t2330.shift(30)
     tReal = Time.getInstance(EnumWeekday.TUESDAY, 00, 00)
     self.assertEqual(tReal, tShift,
                      myMsg("test next day shift", str(tReal), str(tShift)))
Exemplo n.º 16
0
 def tearDown(self):
     Time.removeAll()
Exemplo n.º 17
0
 def testMondayLessThanSunday(self):
     tmon = makeMon1230()
     tsun = Time.getInstance(EnumWeekday.SUNDAY, 12, 30)
     self.assertTrue(tmon < tsun,
                     myMsg("test lt", "monday < sunday", str(tmon < tsun)))
Exemplo n.º 18
0
 def testShiftMon1230by30min(self):
     t1230 = makeMon1230()
     t1300_shifted = t1230.shift(30)
     t1300_real = Time.getInstance(EnumWeekday.MONDAY,13,00)
     self.assertEqual(t1300_real, t1300_shifted, myMsg("test shift", str(t1300_real), str(t1300_shifted))) 
Exemplo n.º 19
0
 def setUp(self):
     TimeRanges.removeAll()
     TimeRange.removeAll()
     Time.removeAll()
Exemplo n.º 20
0
 def testShiftMon2330by30min(self):
     t2330 = Time.getInstance(EnumWeekday.MONDAY, 23, 30)
     tShift = t2330.shift(30)
     tReal = Time.getInstance(EnumWeekday.TUESDAY, 00, 00)
     self.assertEqual(tReal, tShift, myMsg("test next day shift", str(tReal), str(tShift)))
Exemplo n.º 21
0
 def testShiftSUN2330by60min(self):
     t2330 = Time.getInstance(EnumWeekday.SUNDAY, 23, 30)
     tShift = t2330.shift(60)
     tReal = Time.getInstance(EnumWeekday.MONDAY, 00, 30)
     self.assertEqual(tReal, tShift, myMsg("test sunday to monday shift", str(tReal), str(tShift)))
Exemplo n.º 22
0
 def testSameDay1230MoreThan1200(self):
     t1 = makeMon1230()
     t2 = Time.getInstance(EnumWeekday.MONDAY, 12, 00)
     self.assertTrue(
         t1 > t2,
         myMsg("test same day compare", "12:30 > 12:00", str(t1 > t2)))
Exemplo n.º 23
0
 def testMondayLessThanSunday(self):
     tmon = makeMon1230()
     tsun = Time.getInstance(EnumWeekday.SUNDAY, 12, 30)
     self.assertTrue(tmon < tsun, myMsg("test lt", "monday < sunday",  str(tmon<tsun)))
Exemplo n.º 24
0
def getTime(dayNum, hour, min):
    return Time.getInstance(EnumWeekday.fromInt(dayNum), hour, min)
Exemplo n.º 25
0
def getTime(dayNum, hour, min):
    return Time.getInstance(EnumWeekday.fromInt(dayNum), hour, min)