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'], '')
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'), '')
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"], "")
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')
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')
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")
def test_addnew(self): from plone.resourceeditor.browser import FileManager r = self._make_directory() view = FileManager(r, self.layer['request']) info = view.addNew('/', 'test.txt') self.assertEqual(info['code'], 0) self.assertEqual(info['error'], '') self.assertEqual(info['name'], 'test.txt') self.assertEqual(info['parent'], '/') self.assertEqual(r.readFile('test.txt'), b'')
def test_addnew(self): from plone.resourceeditor.browser import FileManager r = self._make_directory() view = FileManager(r, self.layer['request']) info = view.addNew('/', 'test.txt') self.assertEqual(info['code'], 0) self.assertEqual(info['error'], '') self.assertEqual(info['name'], 'test.txt') self.assertEqual(info['parent'], '/') self.assertEqual(r.readFile('test.txt'), '')
def test_addnew(self): from plone.resourceeditor.browser import FileManager r = self._make_directory() view = FileManager(r, self.layer["request"]) info = view.addNew("/", "test.txt") self.assertEqual(info["code"], 0) self.assertEqual(info["error"], "") self.assertEqual(info["name"], "test.txt") self.assertEqual(info["parent"], "/") self.assertEqual(r.readFile("test.txt"), "")