コード例 #1
0
ファイル: test_trash_rm.py プロジェクト: CyrusYip/trash-cli
 def setUp(self):
     require_empty_dir('sandbox')
     self.out = Mock()
     self.listing = ListTrashinfos(self.out,
                                   FileSystemReader(),
                                   None)
     self.index = 0
コード例 #2
0
class TestListTrashinfos(unittest.TestCase):
    def setUp(self):
        self.tmp_dir = MyPath.make_temp_dir()
        self.trash_dir = self.tmp_dir / 'Trash'
        self.fake_trash_dir = FakeTrashDir(self.trash_dir)
        self.listing = ListTrashinfos(FileSystemReader())

    def test_absolute_path(self):
        self.fake_trash_dir.add_trashinfo_basename_path('a', '/foo')

        result = list(
            self.listing.list_from_volume_trashdir(self.trash_dir, '/volume/'))

        assert result == [('trashed_file',
                           ('/foo', '%s/info/a.trashinfo' % self.trash_dir))]

    def test_relative_path(self):
        self.fake_trash_dir.add_trashinfo_basename_path('a', 'foo')

        result = list(
            self.listing.list_from_volume_trashdir(self.trash_dir, '/volume/'))

        assert result == [('trashed_file',
                           ('/volume/foo',
                            '%s/info/a.trashinfo' % self.trash_dir))]

    def tearDown(self):
        self.tmp_dir.clean_up()
コード例 #3
0
 def setUp(self):
     require_empty_dir('sandbox')
     self.out = Mock()
     self.listing = ListTrashinfos(self.out,
                                   FileSystemReader(),
                                   None)
     self.index = 0
コード例 #4
0
class TestListing(unittest.TestCase):
    def setUp(self):
        self.tmp_dir = MyPath.make_temp_dir()
        self.trash_dir = self.tmp_dir / 'Trash'
        self.out = Mock()
        self.listing = ListTrashinfos(self.out, FileSystemReader(), None)
        self.index = 0

    def test_should_report_original_location(self):
        self.add_trashinfo('/foo')

        self.listing.list_from_volume_trashdir(self.trash_dir, '/')

        self.out.assert_called_with('/foo', ANY)

    def test_should_report_trashinfo_path(self):
        self.add_trashinfo(trashinfo_path=self.trash_dir / 'info/a.trashinfo')

        self.listing.list_from_volume_trashdir(self.trash_dir, '/')

        self.out.assert_called_with(ANY, self.trash_dir / 'info/a.trashinfo')

    def test_should_handle_volume_trashdir(self):
        self.add_trashinfo(trashinfo_path=self.tmp_dir /
                           '.Trash/123/info/a.trashinfo')

        self.listing.list_from_volume_trashdir(self.tmp_dir / '.Trash/123',
                                               '/fake/vol')

        self.out.assert_called_with(
            ANY, self.tmp_dir / '.Trash/123/info/a.trashinfo')

    def test_should_absolutize_relative_path_for_volume_trashdir(self):
        self.add_trashinfo(path='foo/bar',
                           trashdir=self.tmp_dir / '.Trash/501')

        self.listing.list_from_volume_trashdir(self.tmp_dir / '.Trash/501',
                                               '/fake/vol')

        self.out.assert_called_with('/fake/vol/foo/bar', ANY)

    def add_trashinfo(self,
                      path='unspecified/original/location',
                      trashinfo_path=None,
                      trashdir=None):
        trashdir = trashdir or self.trash_dir
        trashinfo_path = trashinfo_path or self._trashinfo_path(trashdir)
        make_file(trashinfo_path, a_trashinfo_with_path(path))

    def _trashinfo_path(self, trashdir):
        path = '%s/info/%s.trashinfo' % (trashdir, self.index)
        self.index += 1
        return path
コード例 #5
0
ファイル: test_trash_rm.py プロジェクト: jiuyuechou/trash-cli
class TestListing:
    def setUp(self):
        require_empty_dir('sandbox')
        self.out = Mock()
        self.listing = ListTrashinfos(self.out, FileSystemReader(), None)
        self.index = 0

    def test_should_report_original_location(self):
        self.add_trashinfo('/foo')

        self.listing.list_from_volume_trashdir('sandbox/Trash', '/')

        self.out.assert_called_with('/foo', ANY)

    def test_should_report_trashinfo_path(self):
        self.add_trashinfo(trashinfo_path='sandbox/Trash/info/a.trashinfo')

        self.listing.list_from_volume_trashdir('sandbox/Trash', '/')

        self.out.assert_called_with(ANY, 'sandbox/Trash/info/a.trashinfo')

    def test_should_handle_volume_trashdir(self):
        self.add_trashinfo(
            trashinfo_path='sandbox/.Trash/123/info/a.trashinfo')

        self.listing.list_from_volume_trashdir('sandbox/.Trash/123',
                                               '/fake/vol')

        self.out.assert_called_with(ANY, 'sandbox/.Trash/123/info/a.trashinfo')

    def test_should_absolutize_relative_path_for_volume_trashdir(self):
        self.add_trashinfo(path='foo/bar', trashdir='sandbox/.Trash/501')

        self.listing.list_from_volume_trashdir('sandbox/.Trash/501',
                                               '/fake/vol')

        self.out.assert_called_with('/fake/vol/foo/bar', ANY)

    def add_trashinfo(self,
                      path='unspecified/original/location',
                      trashinfo_path=None,
                      trashdir='sandbox/Trash'):
        trashinfo_path = trashinfo_path or self._trashinfo_path(trashdir)
        write_file(trashinfo_path, a_trashinfo_with_path(path))

    def _trashinfo_path(self, trashdir):
        path = '%s/info/%s.trashinfo' % (trashdir, self.index)
        self.index += 1
        return path
コード例 #6
0
class TestListing:
    def setUp(self):
        require_empty_dir('sandbox')
        self.out = Mock()
        self.listing = ListTrashinfos(self.out,
                                      FileSystemReader(),
                                      None)
        self.index = 0

    def test_should_report_original_location(self):
        self.add_trashinfo('/foo')

        self.listing.list_from_volume_trashdir('sandbox/Trash', '/')

        self.out.assert_called_with('/foo', ANY)

    def test_should_report_trashinfo_path(self):
        self.add_trashinfo(trashinfo_path='sandbox/Trash/info/a.trashinfo')

        self.listing.list_from_volume_trashdir('sandbox/Trash', '/')

        self.out.assert_called_with(ANY, 'sandbox/Trash/info/a.trashinfo')

    def test_should_handle_volume_trashdir(self):
        self.add_trashinfo(trashinfo_path='sandbox/.Trash/123/info/a.trashinfo')

        self.listing.list_from_volume_trashdir('sandbox/.Trash/123',
                                               '/fake/vol')

        self.out.assert_called_with(ANY, 'sandbox/.Trash/123/info/a.trashinfo')

    def test_should_absolutize_relative_path_for_volume_trashdir(self):
        self.add_trashinfo(path='foo/bar', trashdir='sandbox/.Trash/501')

        self.listing.list_from_volume_trashdir('sandbox/.Trash/501',
                                               '/fake/vol')

        self.out.assert_called_with('/fake/vol/foo/bar', ANY)

    def add_trashinfo(self, path='unspecified/original/location',
                            trashinfo_path=None,
                            trashdir='sandbox/Trash'):
        trashinfo_path = trashinfo_path or self._trashinfo_path(trashdir)
        write_file(trashinfo_path, a_trashinfo_with_path(path))
    def _trashinfo_path(self, trashdir):
        path = '%s/info/%s.trashinfo' % (trashdir, self.index)
        self.index +=1
        return path
コード例 #7
0
 def setUp(self):
     self.tmp_dir = MyPath.make_temp_dir()
     self.trash_dir = self.tmp_dir / 'Trash'
     self.out = Mock()
     self.listing = ListTrashinfos(self.out, FileSystemReader(), None)
     self.index = 0
コード例 #8
0
ファイル: test_trash_rm.py プロジェクト: Brijen/trash-cli
 def setUp(self):
     require_empty_dir('sandbox')
     self.out = Mock()
     self.listing = ListTrashinfos(self.out)
     self.index = 0
コード例 #9
0
ファイル: test_trash_rm.py プロジェクト: nestukh/trash-cli
 def setUp(self):
     require_empty_dir('sandbox')
     self.out = Mock()
     self.listing = ListTrashinfos(self.out)
     self.index = 0
コード例 #10
0
 def setUp(self):
     self.tmp_dir = MyPath.make_temp_dir()
     self.trash_dir = self.tmp_dir / 'Trash'
     self.fake_trash_dir = FakeTrashDir(self.trash_dir)
     self.listing = ListTrashinfos(FileSystemReader())