Total Complexity | 6 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 0 |
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 | import things3.things3_cli as 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') |
||
|
|||
16 | |||
17 | def test_methods(self): |
||
18 | for command in self.things3_cli.get_parser()._subparsers._actions[1].choices: |
||
19 | if command != "feedback": |
||
20 | args = self.things3_cli.get_parser().parse_args([command]) |
||
21 | new_out = io.StringIO() |
||
22 | old_out = sys.stdout |
||
23 | try: |
||
24 | sys.stdout = new_out |
||
25 | self.things3_cli.main(args) |
||
26 | finally: |
||
27 | sys.stdout = old_out |
||
28 | self.assertIn(" ", new_out.getvalue()) |
||
29 | |||
30 | def test_today(self): |
||
31 | """Test Today.""" |
||
32 | args = self.things3_cli.get_parser().parse_args(['today']) |
||
33 | new_out = io.StringIO() |
||
34 | old_out = sys.stdout |
||
35 | try: |
||
36 | sys.stdout = new_out |
||
37 | self.things3_cli.main(args) |
||
38 | finally: |
||
39 | sys.stdout = old_out |
||
40 | self.assertIn("Today MIT", new_out.getvalue()) |
||
41 | |||
42 | def test_csv(self): |
||
43 | """Test Next via CSV.""" |
||
44 | args = self.things3_cli.get_parser().parse_args(['-c', 'next']) |
||
45 | new_out = io.StringIO() |
||
46 | old_out = sys.stdout |
||
47 | try: |
||
48 | sys.stdout = new_out |
||
49 | self.things3_cli.main(args) |
||
50 | finally: |
||
51 | sys.stdout = old_out |
||
52 | self.assertIn("FBBB5D059751", new_out.getvalue()) |
||
53 | |||
54 | def test_json(self): |
||
55 | """Test Upcoming via JSON.""" |
||
56 | args = self.things3_cli.get_parser().parse_args(['-j', 'upcoming']) |
||
57 | new_out = io.StringIO() |
||
58 | old_out = sys.stdout |
||
59 | try: |
||
60 | sys.stdout = new_out |
||
61 | self.things3_cli.main(args) |
||
62 | finally: |
||
63 | sys.stdout = old_out |
||
64 | self.assertIn("4F7006C4ADF7", new_out.getvalue()) |
||
65 | |||
66 | |||
67 | if __name__ == '__main__': |
||
68 | unittest.main() |
||
69 |