1 | #!/usr/bin/env python3 |
||
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | """Module documentation goes here.""" |
||
5 | |||
6 | import unittest |
||
7 | import io |
||
8 | import sys |
||
9 | from things3 import things3_cli |
||
10 | |||
11 | |||
12 | class Things3CLICase(unittest.TestCase): |
||
13 | """Class documentation goes here.""" |
||
14 | |||
15 | things3_cli = things3_cli.Things3CLI(database="resources/demo.sqlite3") |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
16 | |||
17 | def test_methods(self): |
||
18 | """Invoke all commands.""" |
||
19 | parser = self.things3_cli.get_parser() |
||
20 | for command in parser._subparsers._actions[1].choices: # pylint: disable=W0212 |
||
21 | if command != "feedback": |
||
22 | args = parser.parse_args([command]) |
||
23 | new_out = io.StringIO() |
||
24 | old_out = sys.stdout |
||
25 | try: |
||
26 | sys.stdout = new_out |
||
27 | self.things3_cli.main(args) |
||
28 | finally: |
||
29 | sys.stdout = old_out |
||
30 | self.assertIn(" ", new_out.getvalue()) |
||
31 | |||
32 | def test_today(self): |
||
33 | """Test Today.""" |
||
34 | args = self.things3_cli.get_parser().parse_args(["today"]) |
||
35 | new_out = io.StringIO() |
||
36 | old_out = sys.stdout |
||
37 | try: |
||
38 | sys.stdout = new_out |
||
39 | self.things3_cli.main(args) |
||
40 | finally: |
||
41 | sys.stdout = old_out |
||
42 | self.assertIn("Today MIT", new_out.getvalue()) |
||
43 | |||
44 | def test_csv(self): |
||
45 | """Test Next via CSV.""" |
||
46 | args = self.things3_cli.get_parser().parse_args(["-c", "next"]) |
||
47 | new_out = io.StringIO() |
||
48 | old_out = sys.stdout |
||
49 | try: |
||
50 | sys.stdout = new_out |
||
51 | self.things3_cli.main(args) |
||
52 | finally: |
||
53 | sys.stdout = old_out |
||
54 | self.assertIn("D82v818cpDQ2NLPZTqWwib", new_out.getvalue()) |
||
55 | |||
56 | def test_json(self): |
||
57 | """Test Upcoming via JSON.""" |
||
58 | args = self.things3_cli.get_parser().parse_args(["-j", "upcoming"]) |
||
59 | new_out = io.StringIO() |
||
60 | old_out = sys.stdout |
||
61 | try: |
||
62 | sys.stdout = new_out |
||
63 | self.things3_cli.main(args) |
||
64 | finally: |
||
65 | sys.stdout = old_out |
||
66 | self.assertIn("SGnEWYTSAcnXBLYuMourDj", new_out.getvalue()) |
||
67 | |||
68 | |||
69 | if __name__ == "__main__": |
||
70 | unittest.main() |
||
71 |