本文整理汇总了Python中plone.resourceeditor.browser.FileManager类的典型用法代码示例。如果您正苦于以下问题:Python FileManager类的具体用法?Python FileManager怎么用?Python FileManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_download
def test_download(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
r.writeFile("test.txt", "foo")
view = FileManager(r, self.layer['request'])
self.assertEqual("foo", view.download("/test.txt"))
示例2: test_download
def test_download(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
r.writeFile('test.txt', b'foo')
view = FileManager(r, self.layer['request'])
self.assertEqual(b'foo', view.download('/test.txt'))
示例3: test_getfolder
def test_getfolder(self):
from plone.resourceeditor.browser import FileManager
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 = FileManager(r, self.layer["request"])
info = view.getFolder("/alpha")
self.assertEqual(len(info), 2)
self.assertEqual(info[0]["code"], 0)
self.assertEqual(info[0]["error"], "")
self.assertEqual(info[0]["fileType"], "dir")
self.assertEqual(info[0]["filename"], "delta")
self.assertEqual(info[0]["path"], "/alpha/delta")
self.assertEqual(info[1]["code"], 0)
self.assertEqual(info[1]["error"], "")
self.assertEqual(info[1]["fileType"], "txt")
self.assertEqual(info[1]["filename"], "beta.txt")
self.assertEqual(info[1]["path"], "/alpha/beta.txt")
示例4: test_getfolder
def test_getfolder(self):
from plone.resourceeditor.browser import FileManager
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 = FileManager(r, self.layer['request'])
info = view.getFolder('/alpha')
self.assertEqual(len(info), 2)
self.assertEqual(info[0]['code'], 0)
self.assertEqual(info[0]['error'], '')
self.assertEqual(info[0]['fileType'], 'dir')
self.assertEqual(info[0]['filename'], 'delta')
self.assertEqual(info[0]['path'], '/alpha/delta')
self.assertEqual(info[1]['code'], 0)
self.assertEqual(info[1]['error'], '')
self.assertEqual(info[1]['fileType'], 'txt')
self.assertEqual(info[1]['filename'], 'beta.txt')
self.assertEqual(info[1]['path'], '/alpha/beta.txt')
示例5: test_resource_created_or_modified
def test_resource_created_or_modified(self):
request = FakeRequest()
r = self._make_directory()
view = FileManager(r, request)
info = view.addNew('/', 'test_tile.yaml')
self.assertEqual(info['code'], 0)
self.assertEqual(info['error'], '')
self.assertEqual(info['name'], 'test_tile.yaml')
self.assertEqual(info['parent'], '/')
self.assertEqual(r.readFile('test_tile.yaml'), '')
示例6: test_addnew_invalidname
def test_addnew_invalidname(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
view = FileManager(r, self.layer['request'])
for char in '\\/:*?"<>':
info = view.addNew('/', 'foo' + char)
self.assertEqual(info['code'], 1)
self.assertNotEqual(info['error'], '')
示例7: test_addnew_invalidname
def test_addnew_invalidname(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
view = FileManager(r, self.layer["request"])
for char in '\\/:*?"<>':
info = view.addNew("/", "foo" + char)
self.assertEqual(info["code"], 1)
self.assertNotEqual(info["error"], "")
示例8: test_delete_notfound
def test_delete_notfound(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
view = FileManager(r, self.layer['request'])
info = view.delete('/test.txt')
self.assertEqual(info['code'], 1)
self.assertNotEqual(info['error'], '')
self.assertEqual(info['path'], '/test.txt')
示例9: test_delete_notfound
def test_delete_notfound(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
view = FileManager(r, self.layer["request"])
info = view.delete("/test.txt")
self.assertEqual(info["code"], 1)
self.assertNotEqual(info["error"], "")
self.assertEqual(info["path"], "/test.txt")
示例10: test_addfolder_invalid_parent
def test_addfolder_invalid_parent(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
view = FileManager(r, self.layer['request'])
info = view.addFolder('/alpha', 'beta')
self.assertEqual(info['code'], 1)
self.assertNotEqual(info['error'], '')
self.assertEqual(info['parent'], '/alpha')
self.assertEqual(info['name'], 'beta')
示例11: test_addfolder_invalid_parent
def test_addfolder_invalid_parent(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
view = FileManager(r, self.layer["request"])
info = view.addFolder("/alpha", "beta")
self.assertEqual(info["code"], 1)
self.assertNotEqual(info["error"], "")
self.assertEqual(info["parent"], "/alpha")
self.assertEqual(info["name"], "beta")
示例12: test_addnew_exists
def test_addnew_exists(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
r.writeFile('test.txt', b'foo')
view = FileManager(r, self.layer['request'])
info = view.addNew('/', 'test.txt')
self.assertEqual(info['code'], 1)
self.assertNotEqual(info['error'], '')
self.assertEqual(r.readFile('test.txt'), b'foo')
示例13: test_addfolder_invalid_name
def test_addfolder_invalid_name(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
r.makeDirectory('alpha')
view = FileManager(r, self.layer['request'])
for char in '\\/:*?"<>':
info = view.addFolder('/', 'foo' + char)
self.assertEqual(info['code'], 1)
self.assertNotEqual(info['error'], '')
self.assertEqual(info['parent'], '/')
self.assertEqual(info['name'], 'foo' + char)
示例14: test_addnew_exists
def test_addnew_exists(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
r.writeFile("test.txt", "foo")
view = FileManager(r, self.layer["request"])
info = view.addNew("/", "test.txt")
self.assertEqual(info["code"], 1)
self.assertNotEqual(info["error"], "")
self.assertEqual(r.readFile("test.txt"), "foo")
示例15: test_move_invalid_parent
def test_move_invalid_parent(self):
from plone.resourceeditor.browser import FileManager
r = self._make_directory()
r.writeFile('test.txt', b'foo')
view = FileManager(r, self.layer['request'])
info = view.move('/test.txt', '/alpha')
self.assertEqual(info['code'], 1)
self.assertNotEqual(info['error'], '')
self.assertEqual(info['newPath'], '/alpha/test.txt')
self.assertTrue('test.txt' in r)