Пример #1
0
 def testRoundTo15Minutes_Down(self):
     timedelta = date.TimeDelta(days=1, hours=10, minutes=7)
     self.assertEqual(date.TimeDelta(days=1, hours=10),
                      timedelta.round(minutes=15))
Пример #2
0
 def testMillisecondsInOneSecond(self):
     timedelta = date.TimeDelta(seconds=1)
     self.assertEqual(1000, timedelta.milliseconds())
Пример #3
0
 def testMillisecondsInOneDay(self):
     timedelta = date.TimeDelta(days=1)
     self.assertEqual(24*60*60*1000, timedelta.milliseconds())
Пример #4
0
 def testRoundTo30Minutes_AlwaysUp(self):
     timedelta = date.TimeDelta(days=1, hours=10, minutes=14)
     self.assertEqual(date.TimeDelta(days=1, hours=10, minutes=30), 
                      timedelta.round(minutes=30, alwaysUp=True))
Пример #5
0
 def testRoundTo1Hour_AlwaysUp(self):
     timedelta = date.TimeDelta(days=1, hours=10, minutes=1)
     self.assertEqual(date.TimeDelta(days=1, hours=11), 
                      timedelta.round(hours=1, alwaysUp=True))
     
Пример #6
0
 def testDuration(self):
     self.assertEqual(date.TimeDelta(days=1), self.effort.duration())
Пример #7
0
 def testPlannedStartDateDayBeforeYesterday(self):
     self.task.setPlannedStartDateTime(self.now - date.TimeDelta(hours=48))
     self.task.setCompletionDateTime(self.now)
     self.assertEqual(self.now + date.ONE_DAY,
                      self.task.plannedStartDateTime())
Пример #8
0
 def testZeroTime(self):
     self.assertEqual('', render.timeSpent(date.TimeDelta()))
Пример #9
0
 def testTenHours(self):
     self.assertEqual('10:00:00',
                      render.timeSpent(date.TimeDelta(hours=10)))
Пример #10
0
 def testOneDayLateWhenActive(self):
     timeLeft = date.TimeDelta(days=-1)
     self.assertEqual('-1 day, 0:00', render.timeLeft(timeLeft, False))
Пример #11
0
 def testOneDayLateWhenCompleted(self):
     timeLeft = date.TimeDelta(days=-1)
     self.assertEqual('', render.timeLeft(timeLeft, True))
Пример #12
0
 def testTwoDaysLeftWhenCompleted(self):
     timeLeft = date.TimeDelta(days=2)
     self.assertEqual('', render.timeLeft(timeLeft, True))
Пример #13
0
 def testTwoDaysLeftWhenActive(self):
     timeLeft = date.TimeDelta(days=2)
     self.assertEqual('2 days, 0:00', render.timeLeft(timeLeft, False))
Пример #14
0
 def __snooze(self, taskWithReminder):
     minutesToSnooze = self.settings.getint('view', 'defaultsnoozetime')
     taskWithReminder.snoozeReminder(
         date.TimeDelta(minutes=minutesToSnooze))
Пример #15
0
    def testFindStartDate(self):
        testString = 'This is a date start[' + date.DateTime.now().replace(
            second=0, microsecond=0).strftime('%Y-%m-%d %H:%M') + ']'
        cmpDate = date.DateTime.now().replace(second=0, microsecond=0)
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M'))

        testString = 'This is a date start[' + date.DateTime.now().replace(
            second=0, microsecond=0).strftime('%Y-%m-%d %H:%M') + ']'
        cmpDate = (date.DateTime.now() + date.TimeDelta(days=1)).replace(
            second=0, microsecond=0)
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertNotEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M'))

        testString = 'This is a date start[2013-13-12]'
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date start[2013-12-32]'
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date start[2013-02-29]'
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date start[20131-12-24]'
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(answer[0], None, 'Nej')
        testString = 'This is a date start[2013-121-24]'
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")
        testString = 'This is a date start[20131-12-241]'
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date start ' + date.DateTime.now().replace(
            second=0, microsecond=0).strftime('%Y-%m-%d %H:%M')
        cmpDate = date.DateTime.now().replace(second=0, microsecond=0)
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date Thursday 10:00'
        cmpDate = (date.DateTime.now() + date.TimeDelta(
            days=(3 - date.DateTime.now().weekday()) % 7 + 1)).replace(
                hour=10, minute=0, second=0, microsecond=0)
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date Thursday'
        cmpDate = (date.DateTime.now() + date.TimeDelta(
            days=(3 - date.DateTime.now().weekday()) % 7 + 1)).replace(
                hour=0, minute=0, second=0, microsecond=0)
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date 10:00'
        cmpDate = date.DateTime.today().replace(hour=10,
                                                minute=0,
                                                second=0,
                                                microsecond=0)
        answer = quickAddParser.Parser().findStartDate(testString)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))
Пример #16
0
 def testNegativeHours(self):
     self.assertEqual('-1:00:00',
                      render.timeSpent(date.TimeDelta(hours=-1)))
Пример #17
0
 def testChangeStart_WithinPeriod(self):
     self.taskList.append(self.task1)
     self.task1.addEffort(self.effort1period1a)
     self.effort1period1a.setStart(self.effort1period1a.getStart() + \
         date.TimeDelta(seconds=1))
     self.assertEqual(2, len(self.effortAggregator))
Пример #18
0
 def testNegativeSeconds(self):
     self.assertEqual('-0:00:01',
                      render.timeSpent(date.TimeDelta(seconds=-1)))
Пример #19
0
 def testMarkCompletedSetsNewReminderIfItWasSetPreviously(self):
     reminder = self.now + date.TimeDelta(seconds=10)
     self.task.setReminder(reminder)
     self.task.setCompletionDateTime()
     self.assertEqual(self.createRecurrence()(reminder),
                      self.task.reminder())
Пример #20
0
 def testNoTimeLeftWhenActive(self):
     timeLeft = date.TimeDelta()
     self.assertEqual('0:00', render.timeLeft(timeLeft, False))
Пример #21
0
 def testPlannedStartAndDueDateInThePast(self):
     self.task.setPlannedStartDateTime(self.now - date.TimeDelta(hours=48))
     self.task.setDueDateTime(self.yesterday)
     self.task.setCompletionDateTime(self.now)
     self.assertEqual(self.now, self.task.plannedStartDateTime())
     self.assertEqual(self.tomorrow, self.task.dueDateTime())
Пример #22
0
 def testNoTimeLeftWhenCompleted(self):
     self.assertEqual('', render.timeLeft(date.TimeDelta(), True))
Пример #23
0
 def testRoundTo1Hour_Up(self):
     timedelta = date.TimeDelta(days=1, hours=10, minutes=30)
     self.assertEqual(date.TimeDelta(days=1, hours=11), timedelta.round(hours=1))
Пример #24
0
 def testSortByBudgetDescending(self):
     self.sorter.sortBy('budget')
     self.sorter.sortAscending(False)
     self.task1.setBudget(date.TimeDelta(100))
     self.assertEqual([self.task1, self.task2], list(self.sorter))
Пример #25
0
 def testHours(self):
     timedelta = date.TimeDelta(hours=2, minutes=15)
     self.assertEqual(2.25, timedelta.hours())
 def testBudget_MoreThan24Hour(self):
     self.task.setBudget(date.TimeDelta(hours=25))
     self.tasksWrittenAndRead = task.TaskList(self.readAndWrite()[0])
     self.assertAttributeWrittenAndRead(self.task, 'budget')
Пример #27
0
 def testMillisecondsInOneHour(self):
     timedelta = date.TimeDelta(hours=1)
     self.assertEqual(60*60*1000, timedelta.milliseconds())
Пример #28
0
    def testFindEndDate(self):
        startDate = date.DateTime(2013, 12, 21, 15, 0)
        testString = 'This is a date end[2013-12-25 15:00]'
        cmpDate = (date.DateTime(2013, 12, 25, 15, 0))
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') if answer[0] is not None else
            'None' + " Cmpdate: " + cmpDate.strftime('%Y-%m-%d %H:%M'))

        testString = 'This is a date end[' + date.DateTime.now().replace(
            second=0, microsecond=0).strftime('%Y-%m-%d %H:%M') + ']'
        cmpDate = (date.DateTime.now() + date.TimeDelta(days=1)).replace(
            second=0, microsecond=0)
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertNotEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M'))

        testString = 'This is a date end[2013-13-12]'
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date end[2013-12-32]'
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date end[2013-02-29]'
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M')
            if answer[0] is not None else 'None' + " Should be: None ")

        testString = 'This is a date end[20131-12-24]'
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') if answer[0] is not None else
            'None' + " Should be: " + startDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date end[2013-121-24]'
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') if answer[0] is not None else
            'None' + " Should be: " + startDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date end[20131-12-241]'
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], None, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M') if answer[0] is not None else
            'None' + " Should be: " + startDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date 2013-12-25 10:00'
        cmpDate = date.DateTime(2013, 12, 25, 10, 0)
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date Thursday 10:00'
        cmpDate = date.DateTime(2013, 12, 26, 10, 0).replace(second=0,
                                                             microsecond=0)
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date Thursday'
        cmpDate = cmpDate = date.DateTime(2013, 12, 26, 0,
                                          0).replace(second=0, microsecond=0)
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))

        testString = 'This is a date 21:00'
        cmpDate = startDate.replace(hour=21, minute=0)
        answer = quickAddParser.Parser().findEndDate(testString, startDate)
        self.assertEqual(
            answer[0], cmpDate, 'Parsed: ' + testString + ' Answer: ' +
            answer[0].strftime('%Y-%m-%d %H:%M:%S') + " Cmpdate: " +
            cmpDate.strftime('%Y-%m-%d %H:%M:%S'))
Пример #29
0
 def testMillisecondsInOneMicrosecond(self):
     timedelta = date.TimeDelta(microseconds=1)
     self.assertEqual(0, timedelta.milliseconds())
Пример #30
0
 def testRoundTo5Minutes_Big(self):
     timedelta = date.TimeDelta(days=10, minutes=10, seconds=30)
     self.assertEqual(date.TimeDelta(days=10, minutes=10),
                      timedelta.round(minutes=5))