DavHau
02dd132e08
- add python modules for qemu protocols: QMP (hardware interactions) and QGA (guest service interaction) - refactor state directory: remove name from path (already contains url) - add impure vm test for basic qmp interaction - simplify existing vm persistance test (factor out shared code) - integrate graceful shutdown into GUI the GUI integration still needs to be improved later: - add fallback in case system doesn't react to powerdown button - shutdown GUI switch fails if VM hasn't been started yet, and then remains in a wrong position
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# from clan_cli.dirs import _get_clan_flake_toplevel
|
|
|
|
# TODO: Reimplement test?
|
|
# def test_get_clan_flake_toplevel(
|
|
# monkeypatch: pytest.MonkeyPatch, temporary_home: Path
|
|
# ) -> None:
|
|
# monkeypatch.chdir(temporary_home)
|
|
# with pytest.raises(ClanError):
|
|
# print(_get_clan_flake_toplevel())
|
|
# (temporary_home / ".git").touch()
|
|
# assert _get_clan_flake_toplevel() == temporary_home
|
|
|
|
# subdir = temporary_home / "subdir"
|
|
# subdir.mkdir()
|
|
# monkeypatch.chdir(subdir)
|
|
# (subdir / ".clan-flake").touch()
|
|
# assert _get_clan_flake_toplevel() == subdir
|
|
|
|
from clan_cli.dirs import clan_key_safe, vm_state_dir
|
|
|
|
|
|
def test_clan_key_safe() -> None:
|
|
assert clan_key_safe("/foo/bar") == "%2Ffoo%2Fbar"
|
|
|
|
|
|
def test_vm_state_dir_identity() -> None:
|
|
dir1 = vm_state_dir("https://some.clan", "vm1")
|
|
dir2 = vm_state_dir("https://some.clan", "vm1")
|
|
assert str(dir1) == str(dir2)
|
|
|
|
|
|
def test_vm_state_dir_no_collision() -> None:
|
|
dir1 = vm_state_dir("/foo/bar", "vm1")
|
|
dir2 = vm_state_dir("https://some.clan", "vm1")
|
|
assert str(dir1) != str(dir2)
|