Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add trash-rm command with test.

  • Loading branch information...
commit ec19acd115ea682c3d15cf50df77f2dd2a9cb00c 1 parent 6fb608d
@andreafrancia authored
View
16 TODO.txt
@@ -14,12 +14,16 @@ Usage example:
2010-11-15 19:27:25 /home/kfrance/handbook/activities.html
TODO:
- - prepare a list_trashinfos that list all trashinfo from all known valid
- trashdirectories
- - test for list_all_original_path_with_trashinfo:
- - make easier understand when a trashdir is skipped
- x remove dependency of Harvester from TrashDirs
- x substitute the depedency of TrashDirs from fs with Validator
+ - add trash-rm command
+ x add trash-rm entry_point in setup.py
+ x add rm.py package to setup.py
+ x write test for trash-rm in entry-point
+ - check setup.py on Linux
+ - write integration test for trash-rm logic
+
+
+To clean:
+ - describe_trash_list -> test_trash_list
How commands get the list of trashed_files?
View
21 integration_tests/test_trash_rm_script.py
@@ -1,24 +1,29 @@
-from nose.tools import istest, assert_equals
+from nose.tools import istest, assert_equals, assert_in
import subprocess
from subprocess import STDOUT, PIPE, check_output, call, Popen
+from assert_equals_with_unidiff import assert_equals_with_unidiff as assert_equals
+from textwrap import dedent
from pprint import pprint
@istest
class WhenNoArgs:
- def test_print_usage(self):
+ def setUp(self):
process = Popen(['python', 'trashcli/rm.py'],
+ env={'PYTHONPATH':'.'},
stdin=None,
stdout=PIPE,
stderr=PIPE)
- (stdout, stderr) = process.communicate()
-
+ (self.stdout, self.stderr) = process.communicate()
process.wait()
+ self.returncode = process.returncode
+
+ def test_should_print_usage_on_standard_error(self):
+ assert_in("Usage:", self.stderr.splitlines())
+
+
+
- result = dict()
- result['stdout'] = stdout
- result['stderr'] = stderr
- result['returncode'] = process.returncode
View
2  setup.py
@@ -23,7 +23,7 @@
'trash-put = trashcli.cmds:put',
'restore-trash = trashcli.cmds:restore',
'trash-empty = trashcli.cmds:empty',
- 'trash-rm = trashcli.cmds:rm',
+ 'trash-rm = trashcli.rm:main',
]
},
data_files = [('share/man/man1', ['man/man1/trash-empty.1',
View
6 tasks/test-scripts-installation
@@ -0,0 +1,6 @@
+# Clean up
+rm env/bin/trash-rm
+
+python setup.py develop --script-dir env/bin
+
+env/bin/trash-rm --help
View
15 trashcli/rm.py
@@ -1,18 +1,23 @@
import os, sys
-def main(argv):
- from trashcli.trash import FileSystemReader, TrashDirs, Harvester
- from trashcli.trash import TopTrashDirRules
+def main():
+ from trashcli.trash import FileSystemReader, TrashDirs, Harvester
+ from trashcli.trash import TopTrashDirRules
+ from trashcli.list_mount_points import mount_points
environ = os.environ
getuid = os.getuid
file_reader = FileSystemReader()
top_trashdir_rules = TopTrashDirRules(file_reader)
trashdirs = TrashDirs(environ, getuid,
+ list_volumes = mount_points,
top_trashdir_rules = top_trashdir_rules)
harvester = Harvester(file_reader)
print 'ciao'
import sys
- sys.stderr.write('xxxxxx')
+ sys.stderr.write('Usage:\n'
+ ' trash-rm PATTERN\n'
+ '\n'
+ 'Please specify PATTERN')
pass
return 8
@@ -41,4 +46,4 @@ def garbage(self, original_path, info_file, backup_copy=None):
self.trashcan.release(info_file)
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main())
View
1  trashcli/trash.py
@@ -457,7 +457,6 @@ def parse(data):
return TrashInfo(path, deletion_date)
import os
-import shutil
from .fs import remove_file, has_sticky_bit
from .fs import move,mkdirs, list_files_in_dir, mkdirs_using_mode, parent_of
Please sign in to comment.
Something went wrong with that request. Please try again.