Passed
Push — master ( 2a7579...a2cb78 )
by Alexander
03:00
created

Things3APICase.test_toggle()   A

Complexity

Conditions 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nop 1
dl 0
loc 10
rs 9.95
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
from things3 import things3_api
9
10
11
class Things3APICase(unittest.TestCase):
12
    """Class documentation goes here."""
13
14
    things3_api = things3_api.Things3API(database='resources/demo.sqlite3')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable things3_api does not seem to be defined.
Loading history...
15
16
    def test_today(self):
17
        """Test Today."""
18
        result = json.loads(self.things3_api.api("today").response[0])
19
        self.assertEqual(2, len(result))
20
21
    def test_not_implemented(self):
22
        """Test not implemented."""
23
        result = self.things3_api.api("not-implemented").status_code
24
        self.assertEqual(404, result)
25
26
    def test_toggle(self):
27
        """Test toggle."""
28
        result = json.loads(self.things3_api.api("next").response[0])
29
        self.assertEqual(30, len(result))
30
        self.things3_api.api_toggle()
31
        result = json.loads(self.things3_api.api("next").response[0])
32
        self.assertEqual(5, len(result))
33
        self.things3_api.api_toggle()
34
        result = json.loads(self.things3_api.api("next").response[0])
35
        self.assertEqual(30, len(result))
36
37
    def test_filter(self):
38
        """Test Filter."""
39
        self.things3_api.api_filter(
40
            'project', 'F736F7F8-C9D5-4F30-B158-3684669985BC')
41
        result = json.loads(self.things3_api.api("next").response[0])
42
        self.assertEqual(27, len(result))
43
        self.things3_api.api_filter_reset()
44
        result = json.loads(self.things3_api.api("next").response[0])
45
        self.assertEqual(30, len(result))
46
47
    def test_get_file(self):
48
        """Test get file."""
49
        result = self.things3_api.on_get(
50
            "/kanban.html").response[0].decode("utf-8")
51
        self.assertIn("kanban.js", result)
52
53
54
if __name__ == '__main__':
55
    unittest.main()
56