summaryrefslogtreecommitdiff
path: root/kronos/tests/test_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'kronos/tests/test_parser.py')
-rw-r--r--kronos/tests/test_parser.py54
1 files changed, 24 insertions, 30 deletions
diff --git a/kronos/tests/test_parser.py b/kronos/tests/test_parser.py
index e7d64a3..1f9ec40 100644
--- a/kronos/tests/test_parser.py
+++ b/kronos/tests/test_parser.py
@@ -9,50 +9,50 @@ Activity Parser Test Suite
9 9
10 10
11from nose.tools import assert_equals 11from nose.tools import assert_equals
12from kronos.parser import ActivityParser 12from kronos.parser import parse_activity
13 13
14 14
15def parse_text(text):
16 return ActivityParser(text).parse()
17
18class TestWhenParsingBasicFormat(object): 15class TestWhenParsingBasicFormat(object):
19 16
20 def test_should_get_activity(self): 17 def test_should_get_activity(self):
21 results = parse_text("my activity, Some cool stuff!@Home") 18 results = parse_activity("my activity@Home, Some cool stuff!")
19 assert_equals(results.activity, "my activity")
20
21 results = parse_activity("my activity")
22 assert_equals(results.activity, "my activity") 22 assert_equals(results.activity, "my activity")
23 23
24 results = parse_text("my activity") 24 results = parse_activity("my activity@Home")
25 assert_equals(results.activity, "my activity") 25 assert_equals(results.activity, "my activity")
26 26
27 results = parse_text("my activity@Home") 27 results = parse_activity("my activity, Some cool stuff!")
28 assert_equals(results.activity, "my activity") 28 assert_equals(results.activity, "my activity")
29 29
30 def test_should_get_description(self): 30 def test_should_get_description(self):
31 results = parse_text("my activity, Some cool stuff!@Home") 31 results = parse_activity("my activity@Home, Some cool stuff!")
32 assert_equals(results.description, "Some cool stuff!") 32 assert_equals(results.description, "Some cool stuff!")
33 33
34 results = parse_text("my activity, Some cool stuff!") 34 results = parse_activity("my activity, Some cool stuff!")
35 assert_equals(results.description, "Some cool stuff!") 35 assert_equals(results.description, "Some cool stuff!")
36 36
37 results = parse_text("my activity") 37 results = parse_activity("my activity")
38 assert_equals(results.description, None) 38 assert_equals(results.description, None)
39 39
40 def test_should_get_category(self): 40 def test_should_get_category(self):
41 results = parse_text("my activity, Some cool stuff!@Home") 41 results = parse_activity("my activity@Home, Some cool stuff!")
42 assert_equals(results.category, "Home") 42 assert_equals(results.category, "Home")
43 43
44 results = parse_text("my activity, Some cool stuff!") 44 results = parse_activity("my activity, Some cool stuff!")
45 assert_equals(results.category, None) 45 assert_equals(results.category, None)
46 46
47 results = parse_text("my activity@Home") 47 results = parse_activity("my activity@Home")
48 assert_equals(results.category, "Home") 48 assert_equals(results.category, "Home")
49 49
50 50
51class TestWhenParsingWithTags(object): 51class TestWhenParsingWithTags(object):
52 52
53 def setup(self): 53 def setup(self):
54 test_input = "my activity, Some cool stuff!@Home #tag1 #tag2" 54 test_input = "my activity@Home, Some cool stuff! #tag1 #tag2"
55 self.results = ActivityParser(test_input).parse() 55 self.results = parse_activity(test_input)
56 56
57 def test_should_get_tags(self): 57 def test_should_get_tags(self):
58 pass 58 pass
@@ -60,30 +60,24 @@ class TestWhenParsingWithTags(object):
60 60
61class TestWhenParsingWithTimeOffset(object): 61class TestWhenParsingWithTimeOffset(object):
62 62
63 def _parse_text(self, text):
64 return ActivityParser(text).parse()
65
66 def test_should_understand_minutes(self): 63 def test_should_understand_minutes(self):
67 test_input = "my activity, Some cool stuff!@Home 10m" 64 test_input = "my activity@Home, Some cool stuff! 10m"
68 test_input = "my activity, Some cool stuff!@Home 10M" 65 test_input = "my activity@Home, Some cool stuff! 10M"
69 66
70 def test_should_understand_hours(self): 67 def test_should_understand_hours(self):
71 test_input = "my activity, Some cool stuff!@Home 10h" 68 test_input = "my activity@Home, Some cool stuff! 10h"
72 test_input = "my activity, Some cool stuff!@Home 10H" 69 test_input = "my activity@Home, Some cool stuff! 10H"
73 70
74 def test_should_understand_seconds(self): 71 def test_should_understand_seconds(self):
75 test_input = "my activity, Some cool stuff!@Home 10s" 72 test_input = "my activity@Home, Some cool stuff! 10s"
76 test_input = "my activity, Some cool stuff!@Home 10S" 73 test_input = "my activity@Home, Some cool stuff! 10S"
77 74
78 75
79class TestWhenParsingWithAbsoluteTime(object): 76class TestWhenParsingWithAbsoluteTime(object):
80 77
81 def _parse_text(self, text):
82 return ActivityParser(text).parse()
83
84 def test_should_understand_military_time(self): 78 def test_should_understand_military_time(self):
85 test_input = "my activity, Some cool stuff!@Home 11:30-14:40" 79 test_input = "my activity@Home, Some cool stuff! 11:30-14:40"
86 80
87 def test_should_understand_simple_time(self): 81 def test_should_understand_simple_time(self):
88 test_input = "my activity, Some cool stuff!@Home 11:30AM-2:40PM" 82 test_input = "my activity@Home, Some cool stuff! 11:30AM-2:40PM"
89 test_input = "my activity, Some cool stuff!@Home 11:30A-2:40P" 83 test_input = "my activity@Home, Some cool stuff! 11:30A-2:40P"