9463: Mock usage corrections on a test that was producing failures on other tests
[arvados.git] / sdk / python / tests / test_collections.py
index bc3c0bf1afc7e292f07f34e3e8450f32b69b8b8f..41c8c011f0ebf01b4cefa4c18117be2ed4eb024a 100644 (file)
@@ -804,6 +804,24 @@ class CollectionWriterTestCase(unittest.TestCase, CollectionTestMixin):
 
 class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
 
+    def test_replication_desired_kept_on_load(self):
+        m = '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt 0:10:count2.txt\n'
+        c1 = Collection(m, replication_desired=1)
+        c1.save_new()
+        loc = c1.manifest_locator()
+        c2 = Collection(loc)
+        self.assertEqual(c1.manifest_text, c2.manifest_text)
+        self.assertEqual(c1.replication_desired, c2.replication_desired)
+
+    def test_replication_desired_not_loaded_if_provided(self):
+        m = '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt 0:10:count2.txt\n'
+        c1 = Collection(m, replication_desired=1)
+        c1.save_new()
+        loc = c1.manifest_locator()
+        c2 = Collection(loc, replication_desired=2)
+        self.assertEqual(c1.manifest_text, c2.manifest_text)
+        self.assertNotEqual(c1.replication_desired, c2.replication_desired)
+
     def test_init_manifest(self):
         m1 = """. 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt
 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md5sum.txt
@@ -922,9 +940,9 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
         c2 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
         d = c2.diff(c1)
-        self.assertEqual(d, [])
+        self.assertEqual(d, [('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
         d = c1.diff(c2)
-        self.assertEqual(d, [])
+        self.assertEqual(d, [('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
 
         self.assertEqual(c1.portable_manifest_text(), c2.portable_manifest_text())
         c1.apply(d)
@@ -946,9 +964,11 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
         c2 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 5348b82a029fd9e971a811ce1f71360b+43 0:10:count1.txt 10:20:count2.txt\n')
         d = c2.diff(c1)
-        self.assertEqual(d, [('del', './count2.txt', c2["count2.txt"])])
+        self.assertEqual(d, [('del', './count2.txt', c2["count2.txt"]),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
         d = c1.diff(c2)
-        self.assertEqual(d, [('add', './count2.txt', c2["count2.txt"])])
+        self.assertEqual(d, [('add', './count2.txt', c2["count2.txt"]),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
 
         self.assertNotEqual(c1.portable_manifest_text(), c2.portable_manifest_text())
         c1.apply(d)
@@ -958,9 +978,11 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n')
         c2 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 5348b82a029fd9e971a811ce1f71360b+43 0:10:count2.txt\n')
         d = c2.diff(c1)
-        self.assertEqual(d, [('del', './foo', c2["foo"])])
+        self.assertEqual(d, [('del', './foo', c2["foo"]),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
         d = c1.diff(c2)
-        self.assertEqual(d, [('add', './foo', c2["foo"])])
+        self.assertEqual(d, [('add', './foo', c2["foo"]),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
 
         self.assertNotEqual(c1.portable_manifest_text(), c2.portable_manifest_text())
         c1.apply(d)
@@ -972,10 +994,12 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
 
         d = c2.diff(c1)
         self.assertEqual(d, [('del', './foo/count3.txt', c2.find("foo/count3.txt")),
-                             ('add', './foo/count2.txt', c1.find("foo/count2.txt"))])
+                             ('add', './foo/count2.txt', c1.find("foo/count2.txt")),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
         d = c1.diff(c2)
         self.assertEqual(d, [('del', './foo/count2.txt', c1.find("foo/count2.txt")),
-                             ('add', './foo/count3.txt', c2.find("foo/count3.txt"))])
+                             ('add', './foo/count3.txt', c2.find("foo/count3.txt")),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
 
         self.assertNotEqual(c1.portable_manifest_text(), c2.portable_manifest_text())
         c1.apply(d)
@@ -985,9 +1009,11 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         c1 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 5348b82a029fd9e971a811ce1f71360b+43 0:10:count2.txt\n')
         c2 = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt 0:3:foo\n')
         d = c2.diff(c1)
-        self.assertEqual(d, [('mod', './foo', c2["foo"], c1["foo"])])
+        self.assertEqual(d, [('mod', './foo', c2["foo"], c1["foo"]),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
         d = c1.diff(c2)
-        self.assertEqual(d, [('mod', './foo', c1["foo"], c2["foo"])])
+        self.assertEqual(d, [('mod', './foo', c1["foo"], c2["foo"]),
+                             ('tok', './count1.txt', c2["count1.txt"], c1["count1.txt"])])
 
         self.assertNotEqual(c1.portable_manifest_text(), c2.portable_manifest_text())
         c1.apply(d)