Skip to content

Commit 12d7175

Browse files
committed
Test high level Mount API with 'local' backend
1 parent aafa5f9 commit 12d7175

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

common/test/test_mount.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,60 @@ def test_symlinks_remove(self, _mock_process_alive):
184184
mntctrl.checkLocks(str(fp.parent), fp.suffix)
185185

186186
self.assertFalse(sym.exists())
187+
188+
189+
class CheckHighLevelLocalMount(pyfakefs_ut.TestCase):
190+
"""Test high-level Mount with 'local' backend.
191+
"""
192+
193+
def setUp(self):
194+
"""Setup a fake filesystem."""
195+
self.setUpPyfakefs(allow_root_user=False)
196+
197+
self.mode = 'local'
198+
199+
# cleanup() happens automatically
200+
# pylint: disable-next=consider-using-with
201+
self._temp_dir = TemporaryDirectory(prefix='bit.')
202+
# Workaround: tempfile and pathlib not compatible yet
203+
self.temp_path = Path(self._temp_dir.name)
204+
205+
self._config_fp = _create_config_file(
206+
parent_path=self.temp_path,
207+
mode=self.mode
208+
)
209+
self.cfg = config.Config(str(self._config_fp))
210+
211+
# setup mount root
212+
fp = Path.cwd() / ''.join(random.choices(string.ascii_letters, k=10))
213+
fp.mkdir()
214+
# pylint: disable-next=protected-access
215+
self.cfg._LOCAL_MOUNT_ROOT = str(fp)
216+
217+
self.mount = mount.Mount(cfg=self.cfg)
218+
219+
def test_first_pre_mount_check(self):
220+
"""preMountCheck always returns True for 'local' mode.
221+
"""
222+
self.assertTrue(self.mount.preMountCheck(first_run=True))
223+
224+
def test_initialised_pre_mount_check(self):
225+
"""preMountCheck always returns True for 'local' mode.
226+
"""
227+
self.assertTrue(self.mount.preMountCheck(first_run=False))
228+
229+
def test_mount(self):
230+
"""mount always returns 'local' for 'local' mode.
231+
"""
232+
self.assertEqual('local', self.mount.mount(check=False))
233+
234+
def test_umount(self):
235+
"""mount.umount always returns None if the hash_id is 'local'
236+
"""
237+
self.assertIsNone(self.mount.umount(hash_id='local'))
238+
239+
def test_remount_to_new_local_mount(self):
240+
"""If the new profile to mount is 'local', `remount` always
241+
returns 'local'.
242+
"""
243+
self.assertEqual('local', self.mount.remount('2', mode='local'))

0 commit comments

Comments
 (0)