def test2(self):
     require_empty_dir('test-disk/dir')
     remove_file('link-to-non-existent')
     os.symlink('test-disk/non-existent', 'link-to-non-existent')
     assert_equals(self.base,
                   parent_path('link-to-non-existent'))
     remove_file('link-to-non-existent')
Example #2
0
 def test2(self):
     require_empty_dir('test-disk/dir')
     remove_file('link-to-non-existent')
     os.symlink('test-disk/non-existent', 'link-to-non-existent')
     assert (self.base ==
                  parent_path('link-to-non-existent'))
     remove_file('link-to-non-existent')
Example #3
0
 def test3(self):
     remove_file('foo')
     remove_file('bar')
     require_empty_dir('foo')
     require_empty_dir('bar')
     os.symlink('../bar/zap', 'foo/zap')
     assert os.path.join(self.base, 'foo') == parent_path('foo/zap')
     remove_file('foo')
     remove_file('bar')
Example #4
0
 def test4(self):
     remove_file('foo')
     remove_file('bar')
     require_empty_dir('foo')
     require_empty_dir('bar')
     os.symlink('../bar/zap', 'foo/zap')
     make_empty_file('bar/zap')
     assert_equal(os.path.join(self.base, 'foo'), parent_path('foo/zap'))
     remove_file('foo')
     remove_file('bar')
 def test3(self):
     remove_file('foo')
     remove_file('bar')
     require_empty_dir('foo')
     require_empty_dir('bar')
     os.symlink('../bar/zap', 'foo/zap')
     assert_equals(os.path.join(self.base,'foo'),
                   parent_path('foo/zap'))
     remove_file('foo')
     remove_file('bar')
Example #6
0
    def test_until_the_restore_intgration(self):
        from trashcli.fs import remove_file
        from trashcli.fs import contents_of
        self.user_reply = '0'
        open('orig_file', 'w').write('original')
        open('info_file', 'w').write('')
        remove_file('parent/path')
        remove_file('parent')

        trashed_file = TrashedFile('parent/path', None, 'info_file',
                                   'orig_file')

        self.cmd.restore_asking_the_user([trashed_file])

        assert_equals('', self.stdout.getvalue())
        assert_equals('', self.stderr.getvalue())
        assert_true(not os.path.exists('info_file'))
        assert_true(not os.path.exists('orig_file'))
        assert_true(os.path.exists('parent/path'))
        assert_equals('original', contents_of('parent/path'))
Example #7
0
    def test_until_the_restore(self):
        from trashcli.fs import remove_file
        from trashcli.fs import contents_of
        self.user_reply = '0'
        file('orig_file', 'w').write('original')
        file('info_file', 'w').write('')
        remove_file('parent/path')
        remove_file('parent')

        trashed_file = TrashedFile(
                'parent/path',
                None,
                'info_file',
                'orig_file')

        self.cmd.restore_asking_the_user([trashed_file])

        assert_equals('', self.stdout.getvalue())
        assert_equals('', self.stderr.getvalue())
        assert_true(not os.path.exists('info_file'))
        assert_true(not os.path.exists('orig_file'))
        assert_true(os.path.exists('parent/path'))
        assert_equals('original', contents_of('parent/path'))
Example #8
0
 def test(self):
     require_empty_dir('other_dir/dir')
     remove_file('dir')
     os.symlink('other_dir/dir', 'dir')
     make_empty_file('dir/foo')
     assert (os.path.join(self.base, 'other_dir/dir') ==
                  parent_path('dir/foo'))
     remove_file('dir')
     remove_file('other_dir')
Example #9
0
 def test(self):
     require_empty_dir('other_dir/dir')
     remove_file('dir')
     os.symlink('other_dir/dir', 'dir')
     having_file('dir/foo')
     assert_equals(os.path.join(self.base, 'other_dir/dir'),
                   parent_path('dir/foo'))
     remove_file('dir')
     remove_file('other_dir')
Example #10
0
 def test(self):
     require_empty_dir('other_dir/dir')
     remove_file('dir')
     os.symlink('other_dir/dir', 'dir')
     having_file('dir/foo')
     assert_equals(os.path.join(self.base,'other_dir/dir'),
                   parent_path('dir/foo'))
     remove_file('dir')
     remove_file('other_dir')
Example #11
0
 def tearDown(self):
     remove_file('info/info_path.trashinfo')
     remove_dir_if_exists('info')
Example #12
0
 def having_a_file_trashed_from_current_dir(self, filename):
     self.having_a_trashed_file(os.path.join(os.getcwd(), filename))
     remove_file(filename)
     assert not os.path.exists(filename)
Example #13
0
 def tearDown(self):
     remove_file('info/info_path.trashinfo')
     remove_dir_if_exists('info')
 def having_a_file_trashed_from_current_dir(self, filename):
     self.having_a_trashed_file(os.path.join(os.getcwd(), filename))
     remove_file(filename)
     assert not os.path.exists(filename)