Example #1
0
class ChatterBox:

    def __init__(self):
        self.pomodoro = None

    def startPomodoro(self):
        if not self.pomodoro:
            self.pomodoro = Pomodoro()
        return self.pomodoro.startPomodoro()

    def stopPomodoro(self):
        if not self.pomodoro:
            return
        return self.pomodoro.endPomodoro()

    def startPomodoroRest(self):
        if self.pomodoro and not self.pomodoro.inprogress:
            self.pomodoro.startRest()

    def stopPomodoroRest(self):
        if self.pomodoro and not self.pomodoro.inprogress:
            self.pomodoro.startRest()

    def process(self, text):
        text = text.lower().split()
        if "pomodoro" in text:
            if _isIn(START_WORDS, text):
                self.startPomodoro()
                return "Starting"
            elif _isIn(STOP_WORDS, text):
                self.stopPomodoro()
                return "Stoping"
        else:
            return "Huh?"
Example #2
0
 def startPomodoro(self):
     if not self.pomodoro:
         self.pomodoro = Pomodoro()
     return self.pomodoro.startPomodoro()
Example #3
0
 def setUp(self):
     self.p = Pomodoro()
Example #4
0
class TestPomodoro():
    def setUp(self):
        self.p = Pomodoro()

    def test_Pomodoro_init(self):
        assert_true(self.p is not None)

    def test_startPomodoro(self):
        assert_equals(True, self.p.startPomodoro())

    def test_startPomodoro_already_started(self):
        self.p.startPomodoro()
        assert_equals(True, self.p.startPomodoro())

    def test_markInterruption(self):
        assert_equals(1, self.p.markInterruption())

    def test_markInterruption_twice(self):
        self.p.markInterruption()
        assert_equals(2, self.p.markInterruption())

    def test_getInterruptionCount(self):
        self.p.markInterruption()
        assert_equals(1, self.p.getInterruptionCount())