-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathtest_empty_end_to_end.py
94 lines (77 loc) · 3.4 KB
/
test_empty_end_to_end.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import unittest
from trashcli import trash
from .. import run_command
from ..support.help_reformatting import reformat_help_message
from ..support.my_path import MyPath
class TestEmptyEndToEnd(unittest.TestCase):
def setUp(self):
self.tmp_dir = MyPath.make_temp_dir()
def test_help(self):
result = run_command.run_command(self.tmp_dir, "trash-empty",
['--help'])
self.assertEqual([reformat_help_message("""\
usage: trash-empty [-h] [--print-completion {bash,zsh,tcsh}] [--version] [-v]
[--trash-dir TRASH_DIR] [--all-users] [-i] [-f] [--dry-run]
[days]
Purge trashed files.
positional arguments:
days
options:
-h, --help show this help message and exit
--print-completion {bash,zsh,tcsh}
print shell completion script
--version show program's version number and exit
-v, --verbose list files that will be deleted
--trash-dir TRASH_DIR
specify the trash directory to use
--all-users empty all trashcan of all the users
-i, --interactive ask before emptying trash directories
-f don't ask before emptying trash directories
--dry-run show which files would have been removed
Report bugs to https://github.com/andreafrancia/trash-cli/issues
"""), '', 0],
[result.reformatted_help(),
result.stderr,
result.exit_code])
def test_h(self):
result = run_command.run_command(self.tmp_dir, "trash-empty",
['-h'])
self.assertEqual(["usage:", '', 0],
[result.stdout[0:6],
result.stderr,
result.exit_code])
def test_version(self):
result = run_command.run_command(self.tmp_dir, "trash-empty",
['--version'])
self.assertEqual(['trash-empty %s\n' % trash.version, '', 0],
[result.stdout,
result.stderr,
result.exit_code])
def test_on_invalid_option(self):
result = run_command.run_command(self.tmp_dir, "trash-empty",
['--wrong-option'])
self.assertEqual(['',
'trash-empty: error: unrecognized arguments: --wrong-option',
2],
[result.stdout,
result.stderr.splitlines()[-1],
result.exit_code])
def test_on_print_time(self):
result = run_command.run_command(
self.tmp_dir, "trash-empty",
['--print-time'],
env={'TRASH_DATE': '1970-12-31T23:59:59'})
self.assertEqual(['1970-12-31T23:59:59\n',
'',
0],
result.all)
def test_on_trash_date_not_parsable(self):
result = run_command.run_command(
self.tmp_dir, "trash-empty",
['--print-time'],
env={'TRASH_DATE': 'not a valid date'})
self.assertEqual(['trash-empty: invalid TRASH_DATE: not a valid date\n',
0],
[result.stderr, result.exit_code])
def tearDown(self):
self.tmp_dir.clean_up()