summaryrefslogtreecommitdiff
path: root/kronos/tests/test_cli.py
blob: 54aef81390e222adc6fb72a46aa8d2177c2141e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# vim: set filencoding=utf8
"""
Test Suite for Command Line UI

@author: Mike Crute (mcrute@ag.com)
@organization: American Greetings Interactive
@date: February 05, 2010
"""


from nose.tools import assert_equals, assert_raises
from kronos.cli import CommandLineUI
from kronos.model import Activity


class TestWhenParsingArgs(object):

    def setup(self):
        args = ['kronos', 'start', 'my action@home', '#stuff', '#good']
        self.ui = CommandLineUI(args)
        self.ui.run()

    def test_should_identify_action(self):
        assert_equals(self.ui.action, 'start')

    def test_should_parse_action(self):
        assert isinstance(self.ui.activity, Activity)
        assert_equals(self.ui.activity.activity, 'my action')
        assert_equals(self.ui.activity.category, 'home')


class TestParsingErrors(object):

    def test_should_exit_if_not_enough_args(self):
        ui = CommandLineUI([])
        assert_raises(SystemExit, ui.run)