X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/89bdd6bf07147ad707125fc3882caebb5402ab09..HEAD:/services/fuse/tests/test_mount.py diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py index 157f55e4a4..eb20c06f11 100644 --- a/services/fuse/tests/test_mount.py +++ b/services/fuse/tests/test_mount.py @@ -2,32 +2,32 @@ # # SPDX-License-Identifier: AGPL-3.0 -from __future__ import absolute_import -from future.utils import viewitems -from builtins import str -from builtins import object -from six import assertRegex +import errno import json import llfuse import logging -import mock import os import subprocess import time import unittest import tempfile +from pathlib import Path +from unittest import mock + import arvados import arvados_fuse as fuse -from . import run_test_server +import parameterized + +from arvados_fuse import fusedir +from . import run_test_server from .integration_test import IntegrationTest from .mount_test_base import MountTestBase from .test_tmp_collection import storage_classes_desired logger = logging.getLogger('arvados.arv-mount') - class AssertWithTimeout(object): """Allow some time for an assertion to pass.""" @@ -54,49 +54,43 @@ class AssertWithTimeout(object): else: self.done = True - +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseMountTest(MountTestBase): def setUp(self): super(FuseMountTest, self).setUp() - cw = arvados.CollectionWriter() + cw = arvados.collection.Collection() + with cw.open('thing1.txt', 'w') as f: + f.write('data 1') + with cw.open('thing2.txt', 'w') as f: + f.write('data 2') - cw.start_new_file('thing1.txt') - cw.write("data 1") - cw.start_new_file('thing2.txt') - cw.write("data 2") + with cw.open('dir1/thing3.txt', 'w') as f: + f.write('data 3') + with cw.open('dir1/thing4.txt', 'w') as f: + f.write('data 4') - cw.start_new_stream('dir1') - cw.start_new_file('thing3.txt') - cw.write("data 3") - cw.start_new_file('thing4.txt') - cw.write("data 4") + with cw.open('dir2/thing5.txt', 'w') as f: + f.write('data 5') + with cw.open('dir2/thing6.txt', 'w') as f: + f.write('data 6') - cw.start_new_stream('dir2') - cw.start_new_file('thing5.txt') - cw.write("data 5") - cw.start_new_file('thing6.txt') - cw.write("data 6") + with cw.open('dir2/dir3/thing7.txt', 'w') as f: + f.write('data 7') + with cw.open('dir2/dir3/thing8.txt', 'w') as f: + f.write('data 8') - cw.start_new_stream('dir2/dir3') - cw.start_new_file('thing7.txt') - cw.write("data 7") + for fnm in ":/.../-/*/ ".split("/"): + with cw.open('edgecases/'+fnm, 'w') as f: + f.write('x') - cw.start_new_file('thing8.txt') - cw.write("data 8") + for fnm in ":/.../-/*/ ".split("/"): + with cw.open('edgecases/dirs/'+fnm+'/x/x', 'w') as f: + f.write('x') - cw.start_new_stream('edgecases') - for f in ":/.../-/*/ ".split("/"): - cw.start_new_file(f) - cw.write('x') - - for f in ":/.../-/*/ ".split("/"): - cw.start_new_stream('edgecases/dirs/' + f) - cw.start_new_file('x/x') - cw.write('x') - - self.testcollection = cw.finish() - self.api.collections().create(body={"manifest_text":cw.manifest_text()}).execute() + self.testcollection = cw.portable_data_hash() + self.test_manifest = cw.manifest_text() + self.api.collections().create(body={"manifest_text": self.test_manifest}).execute() def runTest(self): self.make_mount(fuse.CollectionDirectory, collection_record=self.testcollection) @@ -120,11 +114,12 @@ class FuseMountTest(MountTestBase): 'dir2/dir3/thing7.txt': 'data 7', 'dir2/dir3/thing8.txt': 'data 8'} - for k, v in viewitems(files): + for k, v in files.items(): with open(os.path.join(self.mounttmp, k), 'rb') as f: self.assertEqual(v, f.read().decode()) +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseMagicTest(MountTestBase): def setUp(self, api=None): super(FuseMagicTest, self).setUp(api=api) @@ -135,12 +130,11 @@ class FuseMagicTest(MountTestBase): self.collection_in_test_project = run_test_server.fixture('collections')['foo_collection_in_aproject']['name'] self.collection_in_filter_group = run_test_server.fixture('collections')['baz_file']['name'] - cw = arvados.CollectionWriter() + cw = arvados.collection.Collection() + with cw.open('thing1.txt', 'w') as f: + f.write('data 1') - cw.start_new_file('thing1.txt') - cw.write("data 1") - - self.testcollection = cw.finish() + self.testcollection = cw.portable_data_hash() self.test_manifest = cw.manifest_text() coll = self.api.collections().create(body={"manifest_text":self.test_manifest}).execute() self.test_manifest_pdh = coll['portable_data_hash'] @@ -184,7 +178,7 @@ class FuseMagicTest(MountTestBase): files = {} files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1' - for k, v in viewitems(files): + for k, v in files.items(): with open(os.path.join(self.mounttmp, k), 'rb') as f: self.assertEqual(v, f.read().decode()) @@ -283,6 +277,7 @@ def fuseSharedTestHelper(mounttmp): Test().runTest() +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseSharedTest(MountTestBase): def runTest(self): self.make_mount(fuse.SharedDirectory, @@ -306,7 +301,7 @@ class FuseHomeTest(MountTestBase): 'anonymously_accessible_project'] found_in = 0 found_not_in = 0 - for name, item in viewitems(run_test_server.fixture('collections')): + for name, item in run_test_server.fixture('collections').items(): if 'name' not in item: pass elif item['owner_uuid'] == public_project['uuid']: @@ -343,6 +338,7 @@ def fuseModifyFileTestHelperReadEndContents(mounttmp): self.assertEqual("plnp", f.read()) Test().runTest() +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseModifyFileTest(MountTestBase): def runTest(self): collection = arvados.collection.Collection(api_client=self.api) @@ -363,6 +359,7 @@ class FuseModifyFileTest(MountTestBase): self.pool.apply(fuseModifyFileTestHelperReadEndContents, (self.mounttmp,)) +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseAddFileToCollectionTest(MountTestBase): def runTest(self): collection = arvados.collection.Collection(api_client=self.api) @@ -385,6 +382,7 @@ class FuseAddFileToCollectionTest(MountTestBase): self.assertEqual(["file1.txt", "file2.txt"], sorted(d1)) +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseRemoveFileFromCollectionTest(MountTestBase): def runTest(self): collection = arvados.collection.Collection(api_client=self.api) @@ -416,6 +414,7 @@ def fuseCreateFileTestHelper(mounttmp): pass Test().runTest() +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseCreateFileTest(MountTestBase): def runTest(self): collection = arvados.collection.Collection(api_client=self.api) @@ -441,7 +440,7 @@ class FuseCreateFileTest(MountTestBase): self.assertEqual(["file1.txt"], d1) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. d41d8cd98f00b204e9800998ecf8427e\+0\+A\S+ 0:0:file1\.txt$') @@ -459,6 +458,7 @@ def fuseWriteFileTestHelperReadFile(mounttmp): self.assertEqual(f.read(), "Hello world!") Test().runTest() +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseWriteFileTest(MountTestBase): def runTest(self): collection = arvados.collection.Collection(api_client=self.api) @@ -483,7 +483,7 @@ class FuseWriteFileTest(MountTestBase): self.assertEqual(12, self.operations.read_counter.get()) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') @@ -507,6 +507,7 @@ def fuseUpdateFileTestHelper(mounttmp): Test().runTest() +@parameterized.parameterized_class([{"disk_cache": True}, {"disk_cache": False}]) class FuseUpdateFileTest(MountTestBase): def runTest(self): collection = arvados.collection.Collection(api_client=self.api) @@ -521,7 +522,7 @@ class FuseUpdateFileTest(MountTestBase): self.pool.apply(fuseUpdateFileTestHelper, (self.mounttmp,)) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. daaef200ebb921e011e3ae922dd3266b\+11\+A\S+ 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:11:file1\.txt 22:1:file1\.txt$') @@ -561,7 +562,7 @@ class FuseMkdirTest(MountTestBase): self.pool.apply(fuseMkdirTestHelper, (self.mounttmp,)) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') @@ -628,13 +629,13 @@ class FuseRmTest(MountTestBase): # Starting manifest collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') self.pool.apply(fuseRmTestHelperDeleteFile, (self.mounttmp,)) # Empty directories are represented by an empty file named "." collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'./testdir d41d8cd98f00b204e9800998ecf8427e\+0\+A\S+ 0:0:\\056\n') self.pool.apply(fuseRmTestHelperRmdir, (self.mounttmp,)) @@ -685,13 +686,13 @@ class FuseMvFileTest(MountTestBase): # Starting manifest collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') self.pool.apply(fuseMvFileTestHelperMoveFile, (self.mounttmp,)) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt\n\./testdir d41d8cd98f00b204e9800998ecf8427e\+0\+A\S+ 0:0:\\056\n') @@ -719,7 +720,7 @@ class FuseRenameTest(MountTestBase): # Starting manifest collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') d1 = llfuse.listdir(os.path.join(self.mounttmp)) @@ -735,7 +736,7 @@ class FuseRenameTest(MountTestBase): self.assertEqual(["file1.txt"], d1) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir2 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') @@ -806,7 +807,7 @@ def fuseFileConflictTestHelper(mounttmp, uuid, keeptmp, settings): with open(os.path.join(mounttmp, "file1.txt"), "r") as f: self.assertEqual(f.read(), "bar") - assertRegex(self, d1[1], + self.assertRegex(d1[1], r'file1\.txt~\d\d\d\d\d\d\d\d-\d\d\d\d\d\d~conflict~') with open(os.path.join(mounttmp, d1[1]), "r") as f: @@ -911,7 +912,7 @@ class FuseMvFileBetweenCollectionsTest(MountTestBase): collection1.update() collection2.update() - assertRegex(self, collection1.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") + self.assertRegex(collection1.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") self.assertEqual(collection2.manifest_text(), "") self.pool.apply(fuseMvFileBetweenCollectionsTest2, (self.mounttmp, @@ -922,7 +923,7 @@ class FuseMvFileBetweenCollectionsTest(MountTestBase): collection2.update() self.assertEqual(collection1.manifest_text(), "") - assertRegex(self, collection2.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file2\.txt$") + self.assertRegex(collection2.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file2\.txt$") collection1.stop_threads() collection2.stop_threads() @@ -982,7 +983,7 @@ class FuseMvDirBetweenCollectionsTest(MountTestBase): collection1.update() collection2.update() - assertRegex(self, collection1.manifest_text(), r"\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") + self.assertRegex(collection1.manifest_text(), r"\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") self.assertEqual(collection2.manifest_text(), "") self.pool.apply(fuseMvDirBetweenCollectionsTest2, (self.mounttmp, @@ -993,7 +994,7 @@ class FuseMvDirBetweenCollectionsTest(MountTestBase): collection2.update() self.assertEqual(collection1.manifest_text(), "") - assertRegex(self, collection2.manifest_text(), r"\./testdir2 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") + self.assertRegex(collection2.manifest_text(), r"\./testdir2 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") collection1.stop_threads() collection2.stop_threads() @@ -1088,6 +1089,7 @@ class FuseFsyncTest(FuseMagicTest): class MagicDirApiError(FuseMagicTest): def setUp(self): api = mock.MagicMock() + api.keep.block_cache = mock.MagicMock(cache_max=1) super(MagicDirApiError, self).setUp(api=api) api.collections().get().execute.side_effect = iter([ Exception('API fail'), @@ -1113,7 +1115,10 @@ class MagicDirApiError(FuseMagicTest): class SanitizeFilenameTest(MountTestBase): def test_sanitize_filename(self): - pdir = fuse.ProjectDirectory(1, {}, self.api, 0, project_object=self.api.users().current().execute()) + pdir = fuse.ProjectDirectory( + 1, fuse.Inodes(None), self.api, 0, False, None, + project_object=self.api.users().current().execute(), + ) acceptable = [ "foo.txt", ".foo", @@ -1148,12 +1153,11 @@ class FuseMagicTestPDHOnly(MountTestBase): def setUp(self, api=None): super(FuseMagicTestPDHOnly, self).setUp(api=api) - cw = arvados.CollectionWriter() - - cw.start_new_file('thing1.txt') - cw.write("data 1") + cw = arvados.collection.Collection() + with cw.open('thing1.txt', 'w') as f: + f.write('data 1') - self.testcollection = cw.finish() + self.testcollection = cw.portable_data_hash() self.test_manifest = cw.manifest_text() created = self.api.collections().create(body={"manifest_text":self.test_manifest}).execute() self.testcollectionuuid = str(created['uuid']) @@ -1184,7 +1188,7 @@ class FuseMagicTestPDHOnly(MountTestBase): files = {} files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1' - for k, v in viewitems(files): + for k, v in files.items(): with open(os.path.join(self.mounttmp, k), 'rb') as f: self.assertEqual(v, f.read().decode()) @@ -1211,20 +1215,22 @@ class SlashSubstitutionTest(IntegrationTest): mnt_args = [ '--read-write', '--mount-home', 'zzz', + '--fsns', '[SLASH]' ] def setUp(self): super(SlashSubstitutionTest, self).setUp() - self.api = arvados.safeapi.ThreadSafeApiCache(arvados.config.settings()) - self.api.config = lambda: {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}} + + self.api = arvados.safeapi.ThreadSafeApiCache( + arvados.config.settings(), + version='v1' + ) self.testcoll = self.api.collections().create(body={"name": "foo/bar/baz"}).execute() self.testcolleasy = self.api.collections().create(body={"name": "foo-bar-baz"}).execute() self.fusename = 'foo[SLASH]bar[SLASH]baz' @IntegrationTest.mount(argv=mnt_args) - @mock.patch('arvados.util.get_config_once') - def test_slash_substitution_before_listing(self, get_config_once): - get_config_once.return_value = {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}} + def test_slash_substitution_before_listing(self): self.pool_test(os.path.join(self.mnt, 'zzz'), self.fusename) self.checkContents() @staticmethod @@ -1249,8 +1255,8 @@ class SlashSubstitutionTest(IntegrationTest): f.write('foo') def checkContents(self): - self.assertRegexpMatches(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo) - self.assertRegexpMatches(self.api.collections().get(uuid=self.testcolleasy['uuid']).execute()['manifest_text'], ' f561aaf6') # md5(xxx) + self.assertRegex(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], r' acbd18db') # md5(foo) + self.assertRegex(self.api.collections().get(uuid=self.testcolleasy['uuid']).execute()['manifest_text'], r' f561aaf6') # md5(xxx) @IntegrationTest.mount(argv=mnt_args) @mock.patch('arvados.util.get_config_once') @@ -1258,7 +1264,7 @@ class SlashSubstitutionTest(IntegrationTest): self.testcollconflict = self.api.collections().create(body={"name": self.fusename}).execute() get_config_once.return_value = {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}} self.pool_test(os.path.join(self.mnt, 'zzz'), self.fusename) - self.assertRegexpMatches(self.api.collections().get(uuid=self.testcollconflict['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo) + self.assertRegex(self.api.collections().get(uuid=self.testcollconflict['uuid']).execute()['manifest_text'], r' acbd18db') # md5(foo) # foo/bar/baz collection unchanged, because it is masked by foo[SLASH]bar[SLASH]baz self.assertEqual(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], '') @staticmethod @@ -1274,7 +1280,10 @@ class StorageClassesTest(IntegrationTest): def setUp(self): super(StorageClassesTest, self).setUp() - self.api = arvados.safeapi.ThreadSafeApiCache(arvados.config.settings()) + self.api = arvados.safeapi.ThreadSafeApiCache( + arvados.config.settings(), + version='v1', + ) @IntegrationTest.mount(argv=mnt_args) def test_collection_default_storage_classes(self): @@ -1293,3 +1302,128 @@ class StorageClassesTest(IntegrationTest): @staticmethod def _test_collection_custom_storage_classes(self, coll): self.assertEqual(storage_classes_desired(coll), ['foo']) + +def _readonlyCollectionTestHelper(mounttmp): + f = open(os.path.join(mounttmp, 'thing1.txt'), 'rt') + # Testing that close() doesn't raise an error. + f.close() + +class ReadonlyCollectionTest(MountTestBase): + def setUp(self): + super(ReadonlyCollectionTest, self).setUp() + cw = arvados.collection.Collection() + with cw.open('thing1.txt', 'wt') as f: + f.write("data 1") + cw.save_new(owner_uuid=run_test_server.fixture("groups")["aproject"]["uuid"]) + self.testcollection = cw.api_response() + + def runTest(self): + settings = arvados.config.settings().copy() + settings["ARVADOS_API_TOKEN"] = run_test_server.fixture("api_client_authorizations")["project_viewer"]["api_token"] + self.api = arvados.safeapi.ThreadSafeApiCache(settings, version='v1') + self.make_mount(fuse.CollectionDirectory, collection_record=self.testcollection, enable_write=False) + + self.pool.apply(_readonlyCollectionTestHelper, (self.mounttmp,)) + + +@parameterized.parameterized_class([ + {'root_class': fusedir.ProjectDirectory, 'root_kwargs': { + 'project_object': run_test_server.fixture('users')['admin'], + }}, + {'root_class': fusedir.ProjectDirectory, 'root_kwargs': { + 'project_object': run_test_server.fixture('groups')['public'], + }}, +]) +class UnsupportedCreateTest(MountTestBase): + root_class = None + root_kwargs = {} + + def setUp(self): + super().setUp() + if 'prefs' in self.root_kwargs.get('project_object', ()): + self.root_kwargs['project_object']['prefs'] = {} + self.make_mount(self.root_class, **self.root_kwargs) + # Make sure the directory knows about its top-level ents. + os.listdir(self.mounttmp) + + def test_create(self): + test_path = Path(self.mounttmp, 'test_create') + with self.assertRaises(OSError) as exc_check: + with test_path.open('w'): + pass + self.assertEqual(exc_check.exception.errno, errno.ENOTSUP) + + +# FIXME: IMO, for consistency with the "create inside a project" case, +# these operations should also return ENOTSUP instead of EPERM. +# Right now they're returning EPERM because the clasess' writable() method +# usually returns False, and the Operations class transforms that accordingly. +# However, for cases where the mount will never be writable, I think ENOTSUP +# is a clearer error: it lets the user know they can't fix the problem by +# adding permissions in Arvados, etc. +@parameterized.parameterized_class([ + {'root_class': fusedir.MagicDirectory, + 'preset_dir': 'by_id', + 'preset_file': 'README', + }, + + {'root_class': fusedir.SharedDirectory, + 'root_kwargs': { + 'exclude': run_test_server.fixture('users')['admin']['uuid'], + }, + 'preset_dir': 'Active User', + }, + + {'root_class': fusedir.TagDirectory, + 'root_kwargs': { + 'tag': run_test_server.fixture('links')['foo_collection_tag']['name'], + }, + 'preset_dir': run_test_server.fixture('collections')['foo_collection_in_aproject']['uuid'], + }, + + {'root_class': fusedir.TagsDirectory, + 'preset_dir': run_test_server.fixture('links')['foo_collection_tag']['name'], + }, +]) +class UnsupportedOperationsTest(UnsupportedCreateTest): + preset_dir = None + preset_file = None + + def test_create(self): + test_path = Path(self.mounttmp, 'test_create') + with self.assertRaises(OSError) as exc_check: + with test_path.open('w'): + pass + self.assertEqual(exc_check.exception.errno, errno.EPERM) + + def test_mkdir(self): + test_path = Path(self.mounttmp, 'test_mkdir') + with self.assertRaises(OSError) as exc_check: + test_path.mkdir() + self.assertEqual(exc_check.exception.errno, errno.EPERM) + + def test_rename(self): + src_name = self.preset_dir or self.preset_file + if src_name is None: + return + test_src = Path(self.mounttmp, src_name) + test_dst = test_src.with_name('test_dst') + with self.assertRaises(OSError) as exc_check: + test_src.rename(test_dst) + self.assertEqual(exc_check.exception.errno, errno.EPERM) + + def test_rmdir(self): + if self.preset_dir is None: + return + test_path = Path(self.mounttmp, self.preset_dir) + with self.assertRaises(OSError) as exc_check: + test_path.rmdir() + self.assertEqual(exc_check.exception.errno, errno.EPERM) + + def test_unlink(self): + if self.preset_file is None: + return + test_path = Path(self.mounttmp, self.preset_file) + with self.assertRaises(OSError) as exc_check: + test_path.unlink() + self.assertEqual(exc_check.exception.errno, errno.EPERM)