Passed
Push — master ( 914db1...556204 )
by Alexander
04:15 queued 16s
created

Things3APICase.test_config()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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(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