コード例 #1
0
    def test_download(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', 'foo')

        view = FileManagerActions(r, self.layer['request'])
        self.assertEqual('foo', view.download('/test.txt'))
コード例 #2
0
    def test_download(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', b'foo')

        view = FileManagerActions(r, self.layer['request'])
        self.assertEqual(b'foo', view.download('/test.txt'))
コード例 #3
0
    def test_addnew_invalidname(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        for char in '\\/:*?"<>':
            info = view.addFile('/', 'foo' + char)
            info = json.loads(info)
            self.assertEqual(info['code'], 1)
            self.assertNotEqual(info['error'], '')
コード例 #4
0
    def test_getinfo(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        r.writeFile('test.txt', 'A text file')
        view = FileManagerActions(r, self.layer['request'])
        info = view.getInfo(r['test.txt'])

        self.assertEqual(info['fileType'], 'txt')
        self.assertEqual(info['filename'], 'test.txt')
        self.assertEqual(info['path'], '/')
コード例 #5
0
    def test_getinfo(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        r.writeFile('test.txt', b'A text file')
        view = FileManagerActions(r, self.layer['request'])
        info = view.getInfo(r['test.txt'])

        self.assertEqual(info['fileType'], 'txt')
        self.assertEqual(info['filename'], 'test.txt')
        self.assertEqual(info['path'], '/')
コード例 #6
0
    def test_addnew_invalidname(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        for char in '\\/:*?"<>':
            info = view.addFile('/', 'foo' + char)
            info = json.loads(info)
            self.assertEqual(info['code'], 1)
            self.assertNotEqual(info['error'], '')
コード例 #7
0
    def test_delete_notfound(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        info = view.delete('/test.txt')
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['path'], '/test.txt')
コード例 #8
0
    def test_delete_notfound(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        info = view.delete('/test.txt')
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['path'], '/test.txt')
コード例 #9
0
    def test_addfolder_invalid_parent(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        info = view.addFolder('/alpha', 'beta')
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['parent'], '/alpha')
        self.assertEqual(info['name'], 'beta')
コード例 #10
0
    def test_addfolder_invalid_parent(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        info = view.addFolder('/alpha', 'beta')
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['parent'], '/alpha')
        self.assertEqual(info['name'], 'beta')
コード例 #11
0
    def test_addfolder_exists(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.makeDirectory('alpha')

        view = FileManagerActions(r, self.layer['request'])

        info_str = view.addFolder('/', 'alpha')
        info = json.loads(info_str)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['parent'], '/')
        self.assertEqual(info['name'], 'alpha')
コード例 #12
0
    def test_addfolder_exists(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.makeDirectory('alpha')

        view = FileManagerActions(r, self.layer['request'])

        info_str = view.addFolder('/', 'alpha')
        info = json.loads(info_str)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['parent'], '/')
        self.assertEqual(info['name'], 'alpha')
コード例 #13
0
    def test_move_invalid_parent(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', 'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.move('/test.txt', '/alpha')
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['newPath'], '/alpha/test.txt')

        self.assertTrue('test.txt' in r)
コード例 #14
0
    def test_delete(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', 'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.delete('/test.txt')
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['path'], '/test.txt')

        self.assertFalse('test.txt' in r)
コード例 #15
0
    def test_delete(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', b'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.delete('/test.txt')
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['path'], '/test.txt')

        self.assertFalse('test.txt' in r)
コード例 #16
0
    def test_move_invalid_parent(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', b'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.move('/test.txt', '/alpha')
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')
        self.assertEqual(info['newPath'], '/alpha/test.txt')

        self.assertTrue('test.txt' in r)
コード例 #17
0
    def test_add_exists(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', b'boo')

        view = FileManagerActions(r, self.layer['request'])

        d = 'test.txt'

        info = view.addFile('/', d)
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')

        self.assertEqual(r.readFile('test.txt'), b'boo')
コード例 #18
0
    def test_add_exists(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', 'boo')

        view = FileManagerActions(r, self.layer['request'])

        d = 'test.txt'

        info = view.addFile('/', d)
        info = json.loads(info)

        self.assertEqual(info['code'], 1)
        self.assertNotEqual(info['error'], '')

        self.assertEqual(r.readFile('test.txt'), 'boo')
コード例 #19
0
    def test_add(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        d = 'test.txt'

        info = view.addFile('/', d)
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['name'], 'test.txt')
        self.assertEqual(info['path'], '/')
        self.assertEqual(info['parent'], '/')
コード例 #20
0
    def test_add(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        view = FileManagerActions(r, self.layer['request'])

        d = 'test.txt'

        info = view.addFile('/', d)
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['name'], 'test.txt')
        self.assertEqual(info['path'], '/')
        self.assertEqual(info['parent'], '/')
コード例 #21
0
    def test_move(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.makeDirectory('alpha')
        r.writeFile('test.txt', 'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.move('/test.txt', '/alpha')
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['newPath'], '/alpha/test.txt')

        self.assertFalse('test.txt' in r)
        self.assertEqual('foo', r['alpha'].readFile('test.txt'))
コード例 #22
0
    def test_move(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.makeDirectory('alpha')
        r.writeFile('test.txt', b'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.move('/test.txt', '/alpha')
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['newPath'], '/alpha/test.txt')

        self.assertFalse('test.txt' in r)
        self.assertEqual(b'foo', r['alpha'].readFile('test.txt'))
コード例 #23
0
    def test_rename(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', b'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.renameFile('/test.txt', 'foo.txt')
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['oldName'], 'test.txt')
        self.assertEqual(info['newName'], 'foo.txt')
        self.assertEqual(info['oldParent'], '/')
        self.assertEqual(info['newParent'], '/')

        self.assertEqual(r.readFile('foo.txt'), b'foo')
コード例 #24
0
    def test_rename(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()
        r.writeFile('test.txt', 'foo')

        view = FileManagerActions(r, self.layer['request'])

        info = view.renameFile('/test.txt', 'foo.txt')
        info = json.loads(info)

        self.assertEqual(info['code'], 0)
        self.assertEqual(info['error'], '')
        self.assertEqual(info['oldName'], 'test.txt')
        self.assertEqual(info['newName'], 'foo.txt')
        self.assertEqual(info['oldParent'], '/')
        self.assertEqual(info['newParent'], '/')

        self.assertEqual(r.readFile('foo.txt'), 'foo')
コード例 #25
0
    def test_getfolder(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        r.makeDirectory('alpha')
        r['alpha'].writeFile('beta.txt', 'Beta')
        r['alpha'].makeDirectory('delta')
        r['alpha']['delta'].writeFile('gamma.css', 'body')

        view = FileManagerActions(r, self.layer['request'])
        info = view.getFolder('/alpha')

        self.assertEqual(len(info), 2)
        self.assertEqual(info[0]['fileType'], 'dir')
        self.assertEqual(info[0]['filename'], 'delta')
        self.assertEqual(info[0]['path'], '/alpha/delta/')

        self.assertEqual(info[1]['fileType'], 'txt')
        self.assertEqual(info[1]['filename'], 'beta.txt')
        self.assertEqual(info[1]['path'], '/alpha/beta.txt')
コード例 #26
0
    def test_getfolder(self):
        from plone.resourceeditor.browser import FileManagerActions
        r = self._make_directory()

        r.makeDirectory('alpha')
        r['alpha'].writeFile('beta.txt', b'Beta')
        r['alpha'].makeDirectory('delta')
        r['alpha']['delta'].writeFile('gamma.css', b'body')

        view = FileManagerActions(r, self.layer['request'])
        info = view.getFolder('/alpha')

        self.assertEqual(len(info), 2)
        self.assertEqual(info[0]['fileType'], 'dir')
        self.assertEqual(info[0]['filename'], 'delta')
        self.assertEqual(info[0]['path'], '/alpha/delta/')

        self.assertEqual(info[1]['fileType'], 'txt')
        self.assertEqual(info[1]['filename'], 'beta.txt')
        self.assertEqual(info[1]['path'], '/alpha/beta.txt')