mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-01 18:56:41 +00:00
Alter Adder + Adder tests to look for 'only-files' instead of 'only_files'
This commit is contained in:
parent
74207d8334
commit
18a80d99b1
@ -99,7 +99,7 @@ class Adder:
|
|||||||
if not self.overwrite:
|
if not self.overwrite:
|
||||||
raise ExistingChildError("child '%s' already exists" % name)
|
raise ExistingChildError("child '%s' already exists" % name)
|
||||||
|
|
||||||
if self.overwrite == "only_files" and IDirectoryNode.providedBy(children[name][0]):
|
if self.overwrite == "only-files" and IDirectoryNode.providedBy(children[name][0]):
|
||||||
raise ExistingChildError("child '%s' already exists" % name)
|
raise ExistingChildError("child '%s' already exists" % name)
|
||||||
metadata = children[name][1].copy()
|
metadata = children[name][1].copy()
|
||||||
else:
|
else:
|
||||||
|
@ -967,7 +967,7 @@ class Deleter(GridTestMixin, unittest.TestCase):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
class Adder(unittest.TestCase,
|
class Adder(unittest.TestCase,
|
||||||
testutil.ShouldFailMixin, testutil.StallMixin, ErrorMixin):
|
testutil.ShouldFailMixin, testutil.StallMixin, ErrorMixin):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.client = FakeClient()
|
self.client = FakeClient()
|
||||||
@ -983,10 +983,9 @@ class Adder(unittest.TestCase,
|
|||||||
# root/file2
|
# root/file2
|
||||||
# root/dir1
|
# root/dir1
|
||||||
d = root_node.add_file(u'file1', upload.Data("Important Things",
|
d = root_node.add_file(u'file1', upload.Data("Important Things",
|
||||||
None))
|
None))
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
root_node.add_file(u'file2', upload.Data("Sekrit Codes",
|
root_node.add_file(u'file2', upload.Data("Sekrit Codes", None)))
|
||||||
None)))
|
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
root_node.create_empty_directory(u"dir1"))
|
root_node.create_empty_directory(u"dir1"))
|
||||||
d.addCallback(lambda res: root_node)
|
d.addCallback(lambda res: root_node)
|
||||||
@ -996,14 +995,11 @@ class Adder(unittest.TestCase,
|
|||||||
|
|
||||||
def _test_adder(root_node):
|
def _test_adder(root_node):
|
||||||
d = root_node.set_node(u'file1', filenode)
|
d = root_node.set_node(u'file1', filenode)
|
||||||
|
|
||||||
# We've overwritten file1. Let's try it with a directory
|
# We've overwritten file1. Let's try it with a directory
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
root_node.create_empty_directory(u'dir2'))
|
root_node.create_empty_directory(u'dir2'))
|
||||||
|
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
root_node.set_node(u'dir2', filenode))
|
root_node.set_node(u'dir2', filenode))
|
||||||
|
|
||||||
# We try overwriting a file with a child while also specifying
|
# We try overwriting a file with a child while also specifying
|
||||||
# overwrite=False. We should receive an ExistingChildError
|
# overwrite=False. We should receive an ExistingChildError
|
||||||
# when we do this.
|
# when we do this.
|
||||||
@ -1012,23 +1008,20 @@ class Adder(unittest.TestCase,
|
|||||||
"child 'file1' already exists",
|
"child 'file1' already exists",
|
||||||
root_node.set_node, u"file1",
|
root_node.set_node, u"file1",
|
||||||
filenode, overwrite=False))
|
filenode, overwrite=False))
|
||||||
|
|
||||||
# If we try with a directory, we should see the same thing
|
# If we try with a directory, we should see the same thing
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
self.shouldFail(ExistingChildError, "set_node",
|
self.shouldFail(ExistingChildError, "set_node",
|
||||||
"child 'dir1' already exists",
|
"child 'dir1' already exists",
|
||||||
root_node.set_node, u'dir1', filenode,
|
root_node.set_node, u'dir1', filenode,
|
||||||
overwrite=False))
|
overwrite=False))
|
||||||
|
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
root_node.set_node(u'file1', filenode,
|
root_node.set_node(u'file1', filenode,
|
||||||
overwrite="only_files"))
|
overwrite="only-files"))
|
||||||
|
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
self.shouldFail(ExistingChildError, "set_node",
|
self.shouldFail(ExistingChildError, "set_node",
|
||||||
"child 'dir1' already exists",
|
"child 'dir1' already exists",
|
||||||
root_node.set_node, u'dir1', filenode,
|
root_node.set_node, u'dir1', filenode,
|
||||||
overwrite="only_files"))
|
overwrite="only-files"))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
d.addCallback(_test_adder)
|
d.addCallback(_test_adder)
|
||||||
|
Loading…
Reference in New Issue
Block a user