test_qemu_image.py (794B)
1 import os 2 import pytest 3 4 from aetherscale.qemu import image 5 from aetherscale.qemu.exceptions import QemuException 6 7 8 def test_copies_startup_script_to_vm_dir(tmppath): 9 # Create directories that normally exist in mounted OS 10 (tmppath / 'etc/systemd/system').mkdir(parents=True, exist_ok=True) 11 (tmppath / 'root').mkdir(parents=True, exist_ok=True) 12 13 image.install_startup_script('echo something', tmppath) 14 15 assert os.path.isfile(tmppath / f'root/{image.STARTUP_FILENAME}.sh') 16 assert os.path.isfile( 17 tmppath / f'etc/systemd/system/{image.STARTUP_FILENAME}.service') 18 19 20 def test_mount_invalid_image(tmppath): 21 imagepath = tmppath / 'image.qcow2' 22 imagepath.touch() 23 24 with pytest.raises(QemuException): 25 with image.guestmount(imagepath): 26 pass