c.remove("count1.txt")
self.assertNotIn("count1.txt", c)
self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n", c.manifest_text())
+ with self.assertRaises(arvados.errors.ArgumentError):
+ c.remove("")
+
+ def test_find(self):
+ c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt 0:10:count2.txt\n')
+ self.assertIs(c.find("."), c)
+ self.assertIs(c.find("./count1.txt"), c["count1.txt"])
+ self.assertIs(c.find("count1.txt"), c["count1.txt"])
+ with self.assertRaises(IOError):
+ c.find("/.")
+ with self.assertRaises(arvados.errors.ArgumentError):
+ c.find("")
def test_remove_in_subdir(self):
c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n')
c.copy("count1.txt", "foo/")
self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n", c.manifest_text())
+ def test_rename_file(self):
+ c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
+ c.rename("count1.txt", "count2.txt")
+ self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n", c.manifest_text())
+
+ def test_move_file_to_dir(self):
+ c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
+ c.mkdirs("foo")
+ c.rename("count1.txt", "foo/count2.txt")
+ self.assertEqual("./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n", c.manifest_text())
+
+ def test_move_file_to_other(self):
+ c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
+ c2 = Collection()
+ c2.rename("count1.txt", "count2.txt", source_collection=c1)
+ self.assertEqual("", c1.manifest_text())
+ self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n", c2.manifest_text())
+
def test_clone(self):
c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n')
cl = c.clone()
d = c1.diff(c2)
self.assertEqual(d, [('del', './count1.txt', c1["count1.txt"]),
('add', './count2.txt', c2["count2.txt"])])
- with c1.open("count1.txt", "w") as f:
- f.write("zzzzz")
+ f = c1.open("count1.txt", "w")
+ f.write("zzzzz")
# c1 changed, so it should not be deleted.
c1.apply(d)
c2 = Collection('. 5348b82a029fd9e971a811ce1f71360b+43 0:10:count1.txt')
d = c1.diff(c2)
self.assertEqual(d, [('mod', './count1.txt', c1["count1.txt"], c2["count1.txt"])])
- with c1.open("count1.txt", "w") as f:
- f.write("zzzzz")
+ f = c1.open("count1.txt", "w")
+ f.write("zzzzz")
# c1 changed, so c2 mod will go to a conflict file
c1.apply(d)
d = c1.diff(c2)
self.assertEqual(d, [('del', './count2.txt', c1["count2.txt"]),
('add', './count1.txt', c2["count1.txt"])])
- with c1.open("count1.txt", "w") as f:
- f.write("zzzzz")
+ f = c1.open("count1.txt", "w")
+ f.write("zzzzz")
# c1 added count1.txt, so c2 add will go to a conflict file
c1.apply(d)
c1 = self.create_count_txt()
c1.save()
- c2 = Collection(c1._manifest_locator)
+ c2 = Collection(c1.manifest_locator())
with c2.open("count.txt", "w") as f:
f.write("abcdefg")
c1 = self.create_count_txt()
c1.save()
- c2 = arvados.collection.Collection(c1._manifest_locator)
+ c2 = arvados.collection.Collection(c1.manifest_locator())
with c2.open("count.txt", "w") as f:
f.write("abcdefg")
with c1.open("count.txt", "w") as f:
f.write("XYZ")
- c2 = arvados.collection.Collection(c1._manifest_locator)
+ c2 = arvados.collection.Collection(c1.manifest_locator())
with c2.open("count.txt", "w") as f:
f.write("abcdefg")