Issues (4)

tests/test_things3_api.py (2 issues)

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()
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable things3_api does not seem to be defined.
Loading history...
16
    things3 = things3.Things3(database="resources/demo.sqlite3")
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable things3 does not seem to be defined.
Loading history...
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(5, len(result))
25
26
    def test_areas(self):
27
        """Test areas."""
28
        result = json.loads(self.things3_api.api("areas").response[0])
29
        self.assertEqual(1, len(result))
30
31
    def test_get_tag(self):
32
        """Test tags."""
33
        result = json.loads(self.things3_api.tag("Waiting").response[0])
34
        self.assertEqual(3, len(result))
35
36
    def test_not_implemented(self):
37
        """Test not implemented."""
38
        result = self.things3_api.api("not-implemented").status_code
39
        self.assertEqual(404, result)
40
41
    def test_not_found(self):
42
        """Test not found."""
43
        result = self.things3_api.on_get("sdf").status_code
44
        self.assertEqual(404, result)
45
46
    def test_toggle(self):
47
        """Test toggle."""
48
        result = json.loads(self.things3_api.api("next").response[0])
49
        self.assertEqual(32, len(result))
50
        self.things3_api.test_mode = "project"
51
        result = json.loads(self.things3_api.api("next").response[0])
52
        self.assertEqual(6, len(result))
53
        self.things3_api.test_mode = "task"
54
        result = json.loads(self.things3_api.api("next").response[0])
55
        self.assertEqual(32, len(result))
56
57
    def test_filter(self):
58
        """Test Filter."""
59
        self.things3_api.api_filter("project", "D8A6Aknfmq69iW5noxLfz4")
60
        result = json.loads(self.things3_api.api("next").response[0])
61
        self.assertEqual(2, len(result))
62
        self.things3_api.api_filter_reset()
63
        result = json.loads(self.things3_api.api("next").response[0])
64
        self.assertEqual(32, len(result))
65
66
    def test_get_file(self):
67
        """Test get file."""
68
        result = self.things3_api.on_get("/kanban.html").response[0].decode("utf-8")
69
        self.assertIn("kanban.js", result)
70
71
    def test_config(self):
72
        """Test configuration."""
73
        result = self.things3_api.config_get("TAG_MIT").response[0].decode("utf-8")
74
        self.assertEqual("😀", result)
75
76
77
if __name__ == "__main__":
78
    unittest.main()
79