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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# vim: set filencoding=utf8
"""
Activity Parser Test Suite
@author: Mike Crute (mcrute@ag.com)
@organization: American Greetings Interactive
@date: February 04, 2010
"""
from nose.tools import assert_equals
from kronos.parser import parse_activity
class TestWhenParsingBasicFormat(object):
def test_should_get_activity(self):
results = parse_activity("my activity@Home, Some cool stuff!")
assert_equals(results.activity, "my activity")
results = parse_activity("my activity")
assert_equals(results.activity, "my activity")
results = parse_activity("my activity@Home")
assert_equals(results.activity, "my activity")
results = parse_activity("my activity, Some cool stuff!")
assert_equals(results.activity, "my activity")
def test_should_get_description(self):
results = parse_activity("my activity@Home, Some cool stuff!")
assert_equals(results.description, "Some cool stuff!")
results = parse_activity("my activity, Some cool stuff!")
assert_equals(results.description, "Some cool stuff!")
results = parse_activity("my activity")
assert_equals(results.description, None)
def test_should_get_category(self):
results = parse_activity("my activity@Home, Some cool stuff!")
assert_equals(results.category, "Home")
results = parse_activity("my activity, Some cool stuff!")
assert_equals(results.category, None)
results = parse_activity("my activity@Home")
assert_equals(results.category, "Home")
class TestWhenParsingWithTags(object):
def test_should_get_tags(self):
test = parse_activity("my activity@Home, Some cool stuff! #tag1 #tag2")
assert_equals(test.tags, ['tag1', 'tag2'])
def test_should_not_include_tags_in_description(self):
test = parse_activity("my activity@Home, Some cool stuff! #tag1 #tag2")
assert_equals(test.description, "Some cool stuff!")
def test_should_not_include_tags_in_category(self):
test = parse_activity("my activity@Home #tag1 #tag2")
assert_equals(test.tags, ['tag1', 'tag2'])
assert_equals(test.category, 'Home')
|