|
4 | 4 | """Module documentation goes here."""
|
5 | 5 |
|
6 | 6 | import unittest
|
7 |
| -from things import api |
8 | 7 |
|
| 8 | +import things |
9 | 9 |
|
10 |
| -DEMO_FILEPATH = "tests/main.sqlite" |
| 10 | + |
| 11 | +FILEPATH = dict(filepath="tests/main.sqlite") |
11 | 12 |
|
12 | 13 |
|
13 | 14 | class ThingsCase(unittest.TestCase):
|
14 | 15 | """Class documentation goes here."""
|
15 | 16 |
|
16 | 17 | def test_inbox(self):
|
17 | 18 | """Test inbox."""
|
18 |
| - tasks = api.inbox(filepath=DEMO_FILEPATH) |
| 19 | + tasks = things.inbox(**FILEPATH) |
19 | 20 | self.assertEqual(1, len(tasks))
|
20 | 21 |
|
21 | 22 | def test_upcoming(self):
|
22 | 23 | """Test upcoming."""
|
23 |
| - tasks = api.upcoming(filepath=DEMO_FILEPATH) |
| 24 | + tasks = things.upcoming(**FILEPATH) |
24 | 25 | self.assertEqual(2, len(tasks))
|
25 | 26 |
|
26 | 27 | def test_due(self):
|
27 | 28 | """Test due."""
|
28 |
| - tasks = api.due(filepath=DEMO_FILEPATH) |
| 29 | + tasks = things.due(**FILEPATH) |
29 | 30 | self.assertEqual(1, len(tasks))
|
30 | 31 |
|
31 | 32 | def test_today(self):
|
32 | 33 | """Test today."""
|
33 |
| - tasks = api.today(filepath=DEMO_FILEPATH) |
| 34 | + tasks = things.today(**FILEPATH) |
34 | 35 | self.assertEqual(1, len(tasks))
|
35 | 36 |
|
36 | 37 | def test_anytime(self):
|
37 | 38 | """Test antime."""
|
38 |
| - tasks = api.anytime(filepath=DEMO_FILEPATH) |
| 39 | + tasks = things.anytime(**FILEPATH) |
39 | 40 | self.assertEqual(8, len(tasks))
|
40 | 41 |
|
41 | 42 | def test_logbook(self):
|
42 | 43 | """Test logbook."""
|
43 |
| - tasks = api.logbook(filepath=DEMO_FILEPATH) |
| 44 | + tasks = things.logbook(**FILEPATH) |
44 | 45 | self.assertEqual(21, len(tasks))
|
45 | 46 |
|
46 | 47 | def test_canceled(self):
|
47 | 48 | """Test canceled."""
|
48 |
| - tasks = api.canceled(filepath=DEMO_FILEPATH) |
| 49 | + tasks = things.canceled(**FILEPATH) |
49 | 50 | self.assertEqual(11, len(tasks))
|
50 | 51 |
|
51 | 52 | def test_completed(self):
|
52 | 53 | """Test completed."""
|
53 |
| - tasks = api.completed(filepath=DEMO_FILEPATH) |
| 54 | + tasks = things.completed(**FILEPATH) |
54 | 55 | self.assertEqual(10, len(tasks))
|
55 | 56 |
|
56 | 57 | def test_someday(self):
|
57 | 58 | """Test someday."""
|
58 |
| - tasks = api.someday(filepath=DEMO_FILEPATH) |
| 59 | + tasks = things.someday(**FILEPATH) |
59 | 60 | self.assertEqual(1, len(tasks))
|
60 | 61 |
|
61 | 62 | def test_get(self):
|
62 | 63 | """Test get."""
|
63 |
| - tasks = api.get('wrong_uuid', filepath=DEMO_FILEPATH) |
| 64 | + tasks = things.get("wrong_uuid", **FILEPATH) |
64 | 65 | self.assertEqual(None, tasks)
|
65 |
| - tasks = api.get('Qt2AY87x2QDdowSn9HKTt1', filepath=DEMO_FILEPATH) |
| 66 | + tasks = things.get("wrong_uuid", "NOT FOUND", **FILEPATH) |
| 67 | + self.assertEqual("NOT FOUND", tasks) |
| 68 | + tasks = things.get("Qt2AY87x2QDdowSn9HKTt1", **FILEPATH) |
66 | 69 | self.assertEqual(4, len(tasks))
|
67 | 70 |
|
68 | 71 | def test_todos(self):
|
69 | 72 | """Test all tasks."""
|
70 |
| - tasks = api.todos(start="Anytime", filepath=DEMO_FILEPATH) |
| 73 | + tasks = things.todos(start="Anytime", **FILEPATH) |
71 | 74 | self.assertEqual(5, len(tasks))
|
72 |
| - tasks = api.todos(start="Anytime", status="completed", filepath=DEMO_FILEPATH) |
| 75 | + tasks = things.todos(start="Anytime", status="completed", **FILEPATH) |
73 | 76 | self.assertEqual(6, len(tasks))
|
74 |
| - tasks = api.todos(status="completed", filepath=DEMO_FILEPATH) |
| 77 | + tasks = things.todos(status="completed", **FILEPATH) |
75 | 78 | self.assertEqual(10, len(tasks))
|
76 |
| - tasks = api.todos(include_items=True, filepath=DEMO_FILEPATH) |
| 79 | + tasks = things.todos(include_items=True, **FILEPATH) |
77 | 80 | self.assertEqual(9, len(tasks))
|
78 | 81 | with self.assertRaises(ValueError):
|
79 |
| - api.todos(status="wrong_value", filepath=DEMO_FILEPATH) |
80 |
| - tasks = api.tasks('A2oPvtt4dXoypeoLc8uYzY', filepath=DEMO_FILEPATH) |
| 82 | + things.todos(status="wrong_value", **FILEPATH) |
| 83 | + tasks = things.tasks("A2oPvtt4dXoypeoLc8uYzY", **FILEPATH) |
81 | 84 | self.assertEqual(13, len(tasks))
|
82 | 85 |
|
83 | 86 | def test_tags(self):
|
84 | 87 | """Test all tags."""
|
85 |
| - tags = api.tags(filepath=DEMO_FILEPATH) |
| 88 | + tags = things.tags(**FILEPATH) |
86 | 89 | self.assertEqual(5, len(tags))
|
87 | 90 |
|
88 | 91 | def test_projects(self):
|
89 | 92 | """Test all projects."""
|
90 |
| - projects = api.projects(filepath=DEMO_FILEPATH) |
| 93 | + projects = things.projects(**FILEPATH) |
91 | 94 | self.assertEqual(2, len(projects))
|
92 | 95 |
|
93 | 96 | def test_areas(self):
|
94 | 97 | """Test all test_areas."""
|
95 |
| - test_areas = api.areas(filepath=DEMO_FILEPATH) |
| 98 | + test_areas = things.areas(**FILEPATH) |
96 | 99 | self.assertEqual(1, len(test_areas))
|
97 | 100 |
|
| 101 | + def test_database_version(self): |
| 102 | + """Test database version.""" |
| 103 | + version = things.Database(**FILEPATH).get_version() |
| 104 | + self.assertEqual(18, version) |
| 105 | + |
98 | 106 |
|
99 | 107 | if __name__ == "__main__":
|
100 | 108 | unittest.main()
|
0 commit comments