pmbootstrap-meow/test/test_mount.py
Caleb Connolly 3bfc6474bb
WIP: test: type annotate suffix + pathlib (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00

26 lines
974 B
Python

# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import pmb_test # noqa
import pmb.helpers.mount
def test_umount_all_list(tmpdir):
# Write fake mounts file
fake_mounts = str(tmpdir + "/mounts")
with open(fake_mounts, "w") as handle:
handle.write("source /test/var/cache\n")
handle.write("source /test/home/pmos/packages\n")
handle.write("source /test\n")
handle.write("source /test/proc\n")
handle.write("source /test/dev/loop0p2\\040(deleted)\n")
ret = pmb.helpers.mount.umount_all_list(Path("/no/match"), fake_mounts)
assert ret == []
ret = pmb.helpers.mount.umount_all_list(Path("/test/var/cache"), fake_mounts)
assert ret == ["/test/var/cache"]
ret = pmb.helpers.mount.umount_all_list(Path("/test"), fake_mounts)
assert ret == ["/test/var/cache", "/test/proc", "/test/home/pmos/packages",
"/test/dev/loop0p2", "/test"]