コード例 #1
0
    def test_subrepo(self):
        self.backend.load_dir('external_root', path('external_root'))
        self.backend.load_dir('external_test', path('external_test'))
        item = Item(id='external_root')
        storage = self.backend.acquire(item)

        self.assertEqual(
            storage.file('external_test'),
            {
                u'location': u'http://nohost/plone/workspace/external_test',
                # u'path': '',  # this is basically not set.  Correct?
                u'rev': u'0',
                u'type': u'subrepo',
            })

        self.assertEqual(
            storage.file('external_test/test.txt'), {
                u'location': u'http://nohost/plone/workspace/external_test',
                u'path': 'test.txt',
                u'rev': u'0',
                u'type': u'subrepo',
            })

        self.assertEqual(
            storage.pathinfo('external_test'), {
                u'location': u'http://nohost/plone/workspace/external_test',
                u'rev': u'0',
                u'type': u'subrepo',
            })
コード例 #2
0
    def test_subrepo(self):
        self.backend.load_dir('external_root', path('external_root'))
        self.backend.load_dir('external_test', path('external_test'))
        item = Item(id='external_root')
        storage = self.backend.acquire(item)

        self.assertEqual(storage.file('external_test'), {
            u'location': u'http://nohost/plone/workspace/external_test',
            # u'path': '',  # this is basically not set.  Correct?
            u'rev': u'0',
            u'type': u'subrepo',
        })

        self.assertEqual(storage.file('external_test/test.txt'), {
            u'location': u'http://nohost/plone/workspace/external_test',
            u'path': 'test.txt',
            u'rev': u'0',
            u'type': u'subrepo',
        })

        self.assertEqual(storage.pathinfo('external_test'), {
            u'location': u'http://nohost/plone/workspace/external_test',
            u'rev': u'0',
            u'type': u'subrepo',
        })
コード例 #3
0
 def test_bad_path(self):
     item = Item(id='dummy_a')
     storage = self.backend.acquire(item)
     with self.assertRaises(PathNotFoundError):
         storage.file('no/such/path')
コード例 #4
0
    def test_acquire_basic(self):
        item = Item(id='dummy_a')
        storage = self.backend.acquire(item)
        self.assertEqual(item, storage.context)
        self.assertEqual(storage.rev, '3')
        self.assertEqual(storage.shortrev, '3')
        self.assertEqual(storage.file('file1'),
                         'file2-rev0\nThis is also a test file.\n')
        self.assertEqual(storage.file('dir1/dir2/f2'), 'second file in dir2\n')
        self.assertEqual(storage.files(), [
            'dir1/dir2/f1',
            'dir1/dir2/f2',
            'dir1/dir3/dir4/dir5/info',
            'dir1/f1',
            'dir1/f2',
            'file1',
            'file3',
        ])

        self.assertEqual(storage.basename('dir1/dir3/dir4/dir5/info'), 'info')
        self.assertEqual(storage.listdir(''), ['dir1', 'file1', 'file3'])
        self.assertEqual(storage.listdir('dir1'), ['dir2', 'dir3', 'f1', 'f2'])
        self.assertEqual(storage.listdir('dir1/dir2'), ['f1', 'f2'])

        with self.assertRaises(PathNotFoundError):
            storage.listdir('dir1/no/such/dir')

        # this implementation will raise an error if trying to access a
        # file as directory.

        with self.assertRaises(PathNotDirError):
            storage.listdir('file1')

        # acquire the detailed information associated with this path.
        self.assertEqual(
            storage.pathinfo('dir1'), {
                'basename': 'dir1',
                'size': 0,
                'type': 'folder',
                'date': '2005-03-18 23:12:19',
            })

        # ditto for a file
        self.assertEqual(
            storage.pathinfo('file1'), {
                'basename': 'file1',
                'size': 37,
                'type': 'file',
                'date': '2005-03-18 23:12:19',
            })

        # or something nested deeper
        self.assertEqual(
            storage.pathinfo('dir1/dir3/dir4/dir5/info'), {
                'basename': 'info',
                'size': 32,
                'type': 'file',
                'date': '2005-03-18 23:12:19',
            })

        storage.checkout('0')
        self.assertEqual(storage.rev, '0')
        self.assertEqual(storage.file('file1'),
                         'file1-rev0\nThis is a test file.\n')
        self.assertEqual(storage.files(), ['file1', 'file2'])
        self.assertEqual(storage.listdir(''), ['file1', 'file2'])

        with self.assertRaises(PathNotFoundError):
            storage.listdir('dir1')

        with self.assertRaises(PathNotFoundError):
            storage.pathinfo('dir1')

        self.assertEqual(
            storage.pathinfo('file1'), {
                'basename': 'file1',
                'size': 32,
                'type': 'file',
                'date': '2005-03-18 14:58:31',
            })
コード例 #5
0
 def test_bad_path(self):
     item = Item(id='dummy_a')
     storage = self.backend.acquire(item)
     with self.assertRaises(PathNotFoundError):
         storage.file('no/such/path')
コード例 #6
0
    def test_acquire_basic(self):
        item = Item(id='dummy_a')
        storage = self.backend.acquire(item)
        self.assertEqual(item, storage.context)
        self.assertEqual(storage.rev, '3')
        self.assertEqual(storage.shortrev, '3')
        self.assertEqual(
            storage.file('file1'), 'file2-rev0\nThis is also a test file.\n')
        self.assertEqual(
            storage.file('dir1/dir2/f2'), 'second file in dir2\n')
        self.assertEqual(storage.files(), [
            'dir1/dir2/f1', 'dir1/dir2/f2', 'dir1/dir3/dir4/dir5/info',
            'dir1/f1', 'dir1/f2', 'file1', 'file3',
        ])

        self.assertEqual(storage.basename('dir1/dir3/dir4/dir5/info'), 'info')
        self.assertEqual(storage.listdir(''), ['dir1', 'file1', 'file3'])
        self.assertEqual(storage.listdir('dir1'), ['dir2', 'dir3', 'f1', 'f2'])
        self.assertEqual(storage.listdir('dir1/dir2'), ['f1', 'f2'])

        with self.assertRaises(PathNotFoundError):
            storage.listdir('dir1/no/such/dir')

        # this implementation will raise an error if trying to access a
        # file as directory.

        with self.assertRaises(PathNotDirError):
            storage.listdir('file1')

        # acquire the detailed information associated with this path.
        self.assertEqual(storage.pathinfo('dir1'), {
            'basename': 'dir1',
            'size': 0,
            'type': 'folder',
            'date': '2005-03-18 23:12:19',
        })

        # ditto for a file
        self.assertEqual(storage.pathinfo('file1'), {
            'basename': 'file1',
            'size': 37,
            'type': 'file',
            'date': '2005-03-18 23:12:19',
        })

        # or something nested deeper
        self.assertEqual(storage.pathinfo('dir1/dir3/dir4/dir5/info'), {
            'basename': 'info',
            'size': 32,
            'type': 'file',
            'date': '2005-03-18 23:12:19',
        })

        storage.checkout('0')
        self.assertEqual(storage.rev, '0')
        self.assertEqual(
            storage.file('file1'), 'file1-rev0\nThis is a test file.\n')
        self.assertEqual(storage.files(), ['file1', 'file2'])
        self.assertEqual(storage.listdir(''), ['file1', 'file2'])

        with self.assertRaises(PathNotFoundError):
            storage.listdir('dir1')

        with self.assertRaises(PathNotFoundError):
            storage.pathinfo('dir1')

        self.assertEqual(storage.pathinfo('file1'), {
            'basename': 'file1',
            'size': 32,
            'type': 'file',
            'date': '2005-03-18 14:58:31',
        })