forked from projecthamster/hamster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstuff_test.py
82 lines (70 loc) · 3.24 KB
/
stuff_test.py
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
import sys, os.path
# a convoluted line to add hamster module to absolute path
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
import unittest
from hamster.lib import Fact
class TestActivityInputParsing(unittest.TestCase):
def test_plain_name(self):
# plain activity name
activity = Fact("just a simple case")
self.assertEquals(activity.activity, "just a simple case")
assert activity.category is None
assert activity.start_time is None
assert activity.end_time is None
assert activity.category is None
assert activity.description is None
def test_with_start_time(self):
# with time
activity = Fact("12:35 with start time")
self.assertEquals(activity.activity, "with start time")
self.assertEquals(activity.start_time.strftime("%H:%M"), "12:35")
#rest must be empty
assert activity.category is None
assert activity.end_time is None
assert activity.description is None
def test_with_start_and_end_time(self):
# with time
activity = Fact("12:35-14:25 with start-end time")
self.assertEquals(activity.activity, "with start-end time")
self.assertEquals(activity.start_time.strftime("%H:%M"), "12:35")
self.assertEquals(activity.end_time.strftime("%H:%M"), "14:25")
#rest must be empty
assert activity.category is None
assert activity.description is None
def test_category(self):
# plain activity name
activity = Fact("just a simple case@hamster")
self.assertEquals(activity.activity, "just a simple case")
self.assertEquals(activity.category, "hamster")
assert activity.start_time is None
assert activity.end_time is None
assert activity.description is None
def test_description(self):
# plain activity name
activity = Fact("case, with added description")
self.assertEquals(activity.activity, "case")
self.assertEquals(activity.description, "with added description")
assert activity.category is None
assert activity.start_time is None
assert activity.end_time is None
assert activity.category is None
def test_tags(self):
# plain activity name
activity = Fact("case, with added #de description #and, #some #tags")
self.assertEquals(activity.activity, "case")
self.assertEquals(activity.description, "with added #de description")
self.assertEquals(set(activity.tags), set(["and", "some", "tags"]))
assert activity.category is None
assert activity.start_time is None
assert activity.end_time is None
def test_full(self):
# plain activity name
activity = Fact("1225-1325 case@cat, description #ta non-tag #tag #bag")
self.assertEquals(activity.start_time.strftime("%H:%M"), "12:25")
self.assertEquals(activity.end_time.strftime("%H:%M"), "13:25")
self.assertEquals(activity.activity, "case")
self.assertEquals(activity.category, "cat")
self.assertEquals(activity.description, "description #ta non-tag")
self.assertEquals(set(activity.tags), set(["bag", "tag"]))
if __name__ == '__main__':
unittest.main()