Ejemplo n.º 1
0
 def testPauseAndResumePomodoros(self):
     pomo = Pomodoro()
     # we cannot pause a Pomodoro that has not been started yet
     self.assertRaises( Exception, pomo.pause )
     pomo.start()
     time1 = pomo.getTimeLeft()
     pomo.pause()
     time.sleep(1)
     pomo.resume()
     time2 = pomo.getTimeLeft()
     self.assertTrue( time2 + timedelta(seconds=1) < time1  )
Ejemplo n.º 2
0
 def testPomodoroPausesCounter(self):
     pomo = Pomodoro()
     pomo.start()
     self.assertEquals( pomo.pauses, 0 )
     pomo.pause()
     pomo.resume()
     self.assertEquals( pomo.pauses, 1 )
     i=0
     while i<10:
         pomo.pause()
         pomo.resume()
         i += 1
     self.assertEquals( pomo.pauses, 11 )
Ejemplo n.º 3
0
class TestPomodoroBehaviour(unittest.TestCase):

    def setUp(self):
        self.pomodoro = Pomodoro(self.whenTimeup)
        
    def whenTimeup(self):
        self.timeUp = True

    def test_afterCreation_pomodoroIsNotRunning(self):
        self.assertFalse(self.pomodoro.isRunning())
        
    def test_afterCreation_pomodoroIsNotInterrupted(self):
        self.assertFalse(self.pomodoro.wasInterrupted())
        
    def test_afterCreation_timeRemainingInSecondsIsEquivalentToTwentyFiveMinutes(self):
        self.assertEqual(1500, self.pomodoro.timeRemaining)
        
    def test_interruptingAPomodoroThatIsNotRunningIsANotRunningException(self):
        self.assertRaises(PomodoroNotRunning, self.pomodoro.stop)
        
    def test_startingAPomodoroThatIsAlreadyStartedIsAnAlreadyStartedException(self):
        self.pomodoro.start()
        self.assertRaises(PomodoroAlreadyStarted, self.pomodoro.start)

    def test_afterStarting_PomodoroCallsBackWhenTimesUp(self):
        self.timeUp = False
        self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
        self.pomodoro.start()
        sleep(0.1)
        self.assertTrue(self.timeUp)
        
    def test_afterStarting_isRunningReturnsTrue(self):
        self.pomodoro.start()
        self.assertTrue(self.pomodoro.isRunning())
    
    def test_afterStarting_canQueryTimeRemainingWhileRunning(self):
        self.pomodoro.start()
        self.assertEqual(1500, self.pomodoro.timeRemaining)
        
    def test_afterInterrupting_wasInterruptedReturnsTrue(self):
        self.pomodoro.start()
        self.pomodoro.stop()
        self.assertTrue(self.pomodoro.wasInterrupted())
                
    def test_afterPomodoroIsInterrupted_itWillNoLongerCallBack(self):
        self.timeUp = False
        self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
        self.pomodoro.start()
        self.pomodoro.stop()
        sleep(0.1)
        self.assertFalse(self.timeUp, "whenTimeup should not have been called")
    
    def test_afterInterrupting_isRunningReturnsFalse(self):
        self.pomodoro.start()
        self.pomodoro.stop()
        self.assertFalse(self.pomodoro.isRunning())
        
    def test_afterPomodoroEnds_itsNoLongerRunningNorInterrupted(self):
        self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
        self.pomodoro.start()
        sleep(0.1)
        self.assertFalse(self.pomodoro.isRunning())
        self.assertFalse(self.pomodoro.wasInterrupted())
Ejemplo n.º 4
0
from pomodoro import Pomodoro

pomodoro = Pomodoro()
pomodoro.start()
Ejemplo n.º 5
0
 def start_clicked(self):
     self.start_text.set("Cancel")
     pomodoro = Pomodoro()
     stoppable = pomodoro.start(self.on_pomodoro_step, self.on_pomodoro_end)
     self.start_button.configure(command=lambda: self.cancel_clicked(stoppable))
Ejemplo n.º 6
0
 def testPomodoroNotActiveAfterItsTimePassed(self):
     pomo = Pomodoro(seconds=1)
     pomo.start()
     time.sleep(1)
     self.assertRaises( Exception, pomo.pause )
Ejemplo n.º 7
0
 def testStartAndRestartPomodoros(self):
     pomo = Pomodoro()
     pomo.start()
     self.assertTrue( pomo.getTimeLeft() < timedelta(minutes=25), 'A started pomodoro initiates the countdown' )
     pomo.start()
     self.assertTrue( pomo.getTimeLeft().seconds/60 == 24 )