def test_bug_will_use_top_trashdir_even_with_not_sticky(self): self.fs.mock_add_spec(['isdir', 'islink', 'has_sticky_bit', 'move', 'atomic_write', 'remove_file', 'ensure_dir']) self.fs.isdir.return_value = True self.fs.islink.return_value = False self.fs.has_sticky_bit.return_value = False result = TrashResult(False) self.file_trasher.trash_file('sandbox/foo', None, None, result, self.logger, self.reporter) assert self.fs.mock_calls == [ call.isdir('.Trash'), call.islink('.Trash'), call.has_sticky_bit('.Trash'), call.ensure_dir('.Trash-123/files', 448), call.ensure_dir('.Trash-123/info', 448), call.atomic_write('.Trash-123/info/foo.trashinfo', ANY), call.move('sandbox/foo', '.Trash-123/files/foo') ]
def test_should_skip_top_trash_if_does_not_exists(self): self.fs.mock_add_spec(['isdir', 'islink', 'move', 'atomic_write', 'remove_file', 'ensure_dir']) self.fs.isdir.side_effect = lambda x:['.Trash'][False] self.fs.islink.side_effect = lambda x:['.Trash'][False] self.trashcan.trash('sandbox/foo') assert_equals([ call.isdir('.Trash'), call.islink('.Trash'), call.ensure_dir('.Trash/123/info', 448), call.atomic_write('.Trash/123/info/foo.trashinfo', ANY), call.ensure_dir('.Trash/123/files', 448), call.move('sandbox/foo', '.Trash/123/files/foo') ], self.fs.mock_calls)
def test_should_skip_top_trash_if_does_not_exists(self): self.fs.mock_add_spec([ 'isdir', 'islink', 'move', 'atomic_write', 'remove_file', 'ensure_dir' ]) self.fs.isdir.side_effect = lambda x: ['.Trash'][False] self.fs.islink.side_effect = lambda x: ['.Trash'][False] self.trashcan.trash('sandbox/foo') assert_equals([ call.isdir('.Trash'), call.islink('.Trash'), call.ensure_dir('.Trash/123/info', 448), call.atomic_write('.Trash/123/info/foo.trashinfo', ANY), call.ensure_dir('.Trash/123/files', 448), call.move('sandbox/foo', '.Trash/123/files/foo') ], self.fs.mock_calls)
def test_bug_will_use_top_trashdir_even_with_not_sticky(self): self.fs.mock_add_spec(['isdir', 'islink', 'has_sticky_bit', 'move', 'atomic_write', 'remove_file', 'ensure_dir']) self.fs.isdir.return_value = True self.fs.islink.return_value = False self.fs.has_sticky_bit.return_value = False self.trashcan.trash('sandbox/foo') assert_equal([ call.isdir('.Trash'), call.islink('.Trash'), call.has_sticky_bit('.Trash'), call.ensure_dir('.Trash-123/info', 448), call.atomic_write('.Trash-123/info/foo.trashinfo', ANY), call.ensure_dir('.Trash-123/files', 448), call.move('sandbox/foo', '.Trash-123/files/foo') ], self.fs.mock_calls, self.fs.mock_calls)
def test_bug_will_use_top_trashdir_even_with_not_sticky(self): self.fs.mock_add_spec(['isdir', 'islink', 'has_sticky_bit', 'move', 'atomic_write', 'remove_file', 'ensure_dir']) self.fs.isdir.return_value = True self.fs.islink.return_value = False self.fs.has_sticky_bit.return_value = False self.trashcan.trash('sandbox/foo') assert_equals([ call.isdir('.Trash'), call.islink('.Trash'), call.has_sticky_bit('.Trash'), call.ensure_dir('.Trash-123/info', 448), call.atomic_write('.Trash-123/info/foo.trashinfo', ANY), call.ensure_dir('.Trash-123/files', 448), call.move('sandbox/foo', '.Trash-123/files/foo') ], self.fs.mock_calls, self.fs.mock_calls)
def test_use_of_top_trash_dir_when_sticky(self): self.fs.mock_add_spec([ 'isdir', 'islink', 'has_sticky_bit', 'move', 'atomic_write', 'remove_file', 'ensure_dir' ]) self.fs.isdir.return_value = True self.fs.islink.return_value = False self.fs.has_sticky_bit.return_value = True self.trashcan.trash('sandbox/foo') assert [ call.isdir('.Trash'), call.islink('.Trash'), call.has_sticky_bit('.Trash'), call.ensure_dir('.Trash/123/info', 448), call.atomic_write('.Trash/123/info/foo.trashinfo', ANY), call.ensure_dir('.Trash/123/files', 448), call.move('sandbox/foo', '.Trash/123/files/foo') ] == self.fs.mock_calls