1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
"""Module documentation goes here.""" |
5
|
|
|
|
6
|
|
|
import unittest |
7
|
|
|
import json |
8
|
|
|
import configparser |
9
|
|
|
from things3 import things3, things3_api |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class Things3APICase(unittest.TestCase): |
13
|
|
|
"""Class documentation goes here.""" |
14
|
|
|
|
15
|
|
|
things3_api = things3_api.Things3API() |
|
|
|
|
16
|
|
|
things3 = things3.Things3(database='resources/demo.sqlite3') |
|
|
|
|
17
|
|
|
things3.config = configparser.ConfigParser() |
18
|
|
|
things3.config.read('tests/kanbanviewrc') |
19
|
|
|
things3_api.things3 = things3 |
20
|
|
|
|
21
|
|
|
def test_today(self): |
22
|
|
|
"""Test Today.""" |
23
|
|
|
result = json.loads(self.things3_api.api("today").response[0]) |
24
|
|
|
self.assertEqual(3, len(result)) |
25
|
|
|
|
26
|
|
|
def test_not_implemented(self): |
27
|
|
|
"""Test not implemented.""" |
28
|
|
|
result = self.things3_api.api("not-implemented").status_code |
29
|
|
|
self.assertEqual(404, result) |
30
|
|
|
|
31
|
|
|
def test_toggle(self): |
32
|
|
|
"""Test toggle.""" |
33
|
|
|
result = json.loads(self.things3_api.api("next").response[0]) |
34
|
|
|
self.assertEqual(30, len(result)) |
35
|
|
|
self.things3_api.test_mode = "project" |
36
|
|
|
result = json.loads(self.things3_api.api("next").response[0]) |
37
|
|
|
self.assertEqual(5, len(result)) |
38
|
|
|
self.things3_api.test_mode = "task" |
39
|
|
|
result = json.loads(self.things3_api.api("next").response[0]) |
40
|
|
|
self.assertEqual(30, len(result)) |
41
|
|
|
|
42
|
|
|
def test_filter(self): |
43
|
|
|
"""Test Filter.""" |
44
|
|
|
self.things3_api.api_filter( |
45
|
|
|
'project', 'F736F7F8-C9D5-4F30-B158-3684669985BC') |
46
|
|
|
result = json.loads(self.things3_api.api("next").response[0]) |
47
|
|
|
self.assertEqual(27, len(result)) |
48
|
|
|
self.things3_api.api_filter_reset() |
49
|
|
|
result = json.loads(self.things3_api.api("next").response[0]) |
50
|
|
|
self.assertEqual(30, len(result)) |
51
|
|
|
|
52
|
|
|
def test_get_file(self): |
53
|
|
|
"""Test get file.""" |
54
|
|
|
result = self.things3_api.on_get( |
55
|
|
|
"/kanban.html").response[0].decode("utf-8") |
56
|
|
|
self.assertIn("kanban.js", result) |
57
|
|
|
|
58
|
|
|
def test_config(self): |
59
|
|
|
"""Test configuration.""" |
60
|
|
|
result = self.things3_api.config_get('TAG_MIT').response[0] |
61
|
|
|
self.assertEqual(b"MIT", result) |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
if __name__ == '__main__': |
65
|
|
|
unittest.main() |
66
|
|
|
|