X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/47f4f1b26cdebb4ea9b52ac36e6d14f634531ebc..cfcfa1c48d95a07bb961baeef8d7658ddecce41e:/sdk/python/tests/test_collections.py diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py index 5e1a055d48..13fc88def3 100644 --- a/sdk/python/tests/test_collections.py +++ b/sdk/python/tests/test_collections.py @@ -883,6 +883,24 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin): c.copy("count1.txt", "foo/") self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n", c.portable_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() @@ -982,8 +1000,8 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin): 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) @@ -994,12 +1012,12 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin): 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) - self.assertRegexpMatches(c1.portable_manifest_text(), r"\. 95ebc3c7b3b9f1d2c40fec14415d3cb8\+5 5348b82a029fd9e971a811ce1f71360b\+43 0:5:count1\.txt 5:10:count1\.txt~conflict-\d\d\d\d-\d\d-\d\d-\d\d:\d\d:\d\d~$") + self.assertRegexpMatches(c1.portable_manifest_text(), r"\. 95ebc3c7b3b9f1d2c40fec14415d3cb8\+5 5348b82a029fd9e971a811ce1f71360b\+43 0:5:count1\.txt 5:10:count1\.txt~\d\d\d\d\d\d\d\d-\d\d\d\d\d\d~conflict~$") def test_conflict_add(self): c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n') @@ -1007,12 +1025,12 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin): 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) - self.assertRegexpMatches(c1.portable_manifest_text(), r"\. 95ebc3c7b3b9f1d2c40fec14415d3cb8\+5 5348b82a029fd9e971a811ce1f71360b\+43 0:5:count1\.txt 5:10:count1\.txt~conflict-\d\d\d\d-\d\d-\d\d-\d\d:\d\d:\d\d~$") + self.assertRegexpMatches(c1.portable_manifest_text(), r"\. 95ebc3c7b3b9f1d2c40fec14415d3cb8\+5 5348b82a029fd9e971a811ce1f71360b\+43 0:5:count1\.txt 5:10:count1\.txt~\d\d\d\d\d\d\d\d-\d\d\d\d\d\d~conflict~$") def test_conflict_del(self): c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt') @@ -1023,7 +1041,7 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin): # c1 deleted, so c2 mod will go to a conflict file c1.apply(d) - self.assertRegexpMatches(c1.portable_manifest_text(), r"\. 5348b82a029fd9e971a811ce1f71360b\+43 0:10:count1\.txt~conflict-\d\d\d\d-\d\d-\d\d-\d\d:\d\d:\d\d~$") + self.assertRegexpMatches(c1.portable_manifest_text(), r"\. 5348b82a029fd9e971a811ce1f71360b\+43 0:10:count1\.txt~\d\d\d\d\d\d\d\d-\d\d\d\d\d\d~conflict~$") def test_notify(self): c1 = Collection() @@ -1126,7 +1144,7 @@ class CollectionCreateUpdateTest(run_test_server.TestCaseWithServers): c2.save() c1.update() - self.assertRegexpMatches(c1.manifest_text(), r"\. e65075d550f9b5bf9992fa1d71a131be\+3 7ac66c0f148de9519b8bd264312c4d64\+7\+A[a-f0-9]{40}@[a-f0-9]{8} 0:3:count\.txt 3:7:count\.txt~conflict-\d\d\d\d-\d\d-\d\d-\d\d:\d\d:\d\d~$") + self.assertRegexpMatches(c1.manifest_text(), r"\. e65075d550f9b5bf9992fa1d71a131be\+3 7ac66c0f148de9519b8bd264312c4d64\+7\+A[a-f0-9]{40}@[a-f0-9]{8} 0:3:count\.txt 3:7:count\.txt~\d\d\d\d\d\d\d\d-\d\d\d\d\d\d~conflict~$") if __name__ == '__main__':