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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# 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 setup(self):
test_input = "my activity@Home, Some cool stuff! #tag1 #tag2"
self.results = parse_activity(test_input)
def test_should_get_tags(self):
assert_equals(self.results.tags, ['tag1', 'tag2'])
def test_should_not_include_tags_in_description(self):
assert_equals(self.results.description, "Some cool stuff!")
# TODO: Implement this functionality when I need it.
class TestWhenParsingWithTimeOffset(object):
def test_should_understand_minutes(self):
test_input = "my activity@Home, Some cool stuff! 10m"
test_input = "my activity@Home, Some cool stuff! 10M"
def test_should_understand_hours(self):
test_input = "my activity@Home, Some cool stuff! 10h"
test_input = "my activity@Home, Some cool stuff! 10H"
def test_should_understand_seconds(self):
test_input = "my activity@Home, Some cool stuff! 10s"
test_input = "my activity@Home, Some cool stuff! 10S"
class TestWhenParsingWithAbsoluteTime(object):
def test_should_understand_military_time(self):
test_input = "my activity@Home, Some cool stuff! 11:30-14:40"
def test_should_understand_simple_time(self):
test_input = "my activity@Home, Some cool stuff! 11:30AM-2:40PM"
test_input = "my activity@Home, Some cool stuff! 11:30A-2:40P"
|