Documentation: fix typo.
[arvados.git] / services / fuse / tests / test_tmp_collection.py
index a70df8822524f66e449051092c9b06f3d6c6b325..c59024267a4b628dee6948c8259ac7bcda8257e4 100644 (file)
@@ -3,6 +3,7 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 from builtins import range
+from six import assertRegex
 import arvados
 import arvados_fuse
 import arvados_fuse.command
@@ -54,10 +55,12 @@ class TmpCollectionArgsTest(unittest.TestCase):
 
 
 def current_manifest(tmpdir):
-    return json.load(open(
-        os.path.join(tmpdir, '.arvados#collection')
-    ))['manifest_text']
+    with open(os.path.join(tmpdir, '.arvados#collection')) as tmp:
+        return json.load(tmp)['manifest_text']
 
+def storage_classes_desired(tmpdir):
+    with open(os.path.join(tmpdir, '.arvados#collection')) as tmp:
+        return json.load(tmp)['storage_classes_desired']
 
 class TmpCollectionTest(IntegrationTest):
     mnt_args = [
@@ -65,6 +68,13 @@ class TmpCollectionTest(IntegrationTest):
         '--mount-tmp', 'zzz',
     ]
 
+    @IntegrationTest.mount(argv=mnt_args+['--storage-classes', 'foo, bar'])
+    def test_storage_classes(self):
+        self.pool_test(os.path.join(self.mnt, 'zzz'))
+    @staticmethod
+    def _test_storage_classes(self, zzz):
+        self.assertEqual(storage_classes_desired(zzz), ['foo', 'bar'])
+
     @IntegrationTest.mount(argv=mnt_args+['--mount-tmp', 'yyy'])
     def test_two_tmp(self):
         self.pool_test(os.path.join(self.mnt, 'zzz'),
@@ -97,7 +107,8 @@ class TmpCollectionTest(IntegrationTest):
     def _test_tmp_onefile(self, tmpdir):
         with open(os.path.join(tmpdir, 'foo'), 'w') as f:
             f.write('foo')
-        self.assertRegexpMatches(
+        assertRegex(
+            self,
             current_manifest(tmpdir),
             r'^\. acbd18db4cc2f85cedef654fccc4a4d8\+3(\+\S+)? 0:3:foo\n$')
 
@@ -126,7 +137,7 @@ class TmpCollectionTest(IntegrationTest):
                 else:
                     with open(path, 'w') as f:
                         f.write(content)
-                self.assertRegexpMatches(current_manifest(tmpdir), expect)
+                assertRegex(self, current_manifest(tmpdir), expect)
 
     @IntegrationTest.mount(argv=mnt_args)
     def test_tmp_rewrite(self):
@@ -139,4 +150,4 @@ class TmpCollectionTest(IntegrationTest):
             f.write("b2")
         with open(os.path.join(tmpdir, "b1"), 'w') as f:
             f.write("1b")
-        self.assertRegexpMatches(current_manifest(tmpdir), "^\. ed4f3f67c70b02b29c50ce1ea26666bd\+4(\+\S+)? 0:2:b1 2:2:b2\n$")
+        assertRegex(self, current_manifest(tmpdir), "^\. ed4f3f67c70b02b29c50ce1ea26666bd\+4(\+\S+)? 0:2:b1 2:2:b2\n$")