3198: Support for mkdir, rmdir, unlink, rename. Improve exception catching.
[arvados.git] / sdk / python / tests / test_collections.py
index cba14adcc7934f00cee2ddcac8a34953e932de79..8cf34f0282655fd88f27330ec96e5e0b362370cc 100644 (file)
@@ -835,6 +835,18 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         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')
@@ -1065,7 +1077,7 @@ class CollectionCreateUpdateTest(run_test_server.TestCaseWithServers):
         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")
 
@@ -1093,7 +1105,7 @@ class CollectionCreateUpdateTest(run_test_server.TestCaseWithServers):
         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")
 
@@ -1111,7 +1123,7 @@ class CollectionCreateUpdateTest(run_test_server.TestCaseWithServers):
         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")