"""Tests for backends/protocol.py. Covers VmState, VmHandle, and the Protocol stub bodies (the ``...`` ellipsis in each method), which exist as documentation-level defaults and are callable on the Protocol class itself. """ from __future__ import annotations import pytest from ci_orchestrator.backends.protocol import VmBackend, VmHandle, VmState def test_vm_state_values() -> None: assert VmState.POWERED_OFF == "powered_off" assert VmState.POWERED_ON == "powered_on" assert VmState.SUSPENDED == "suspended" assert VmState.UNKNOWN == "unknown" def test_vm_handle_fields() -> None: h = VmHandle(identifier="x.vmx", name="job-1") assert h.identifier == "x.vmx" assert h.name == "job-1" def test_vm_handle_name_defaults_to_none() -> None: h = VmHandle(identifier="x.vmx") assert h.name is None def test_vm_handle_is_frozen() -> None: h = VmHandle("x.vmx") with pytest.raises((AttributeError, TypeError)): h.identifier = "y.vmx" # type: ignore[misc] # ── Protocol stub bodies (lines 53, 57, 61, 65, 69, 73, 81) ────────────────── # The Protocol stubs are callable as default implementations that return None. # Exercising them satisfies coverage without asserting behaviour (they are # documentation stubs, not functional implementations). def test_protocol_stubs_are_callable() -> None: # Protocol.__init__ blocks VmBackend() in Python 3.12; bypass via __new__. b: VmBackend = object.__new__(VmBackend) h = VmHandle("x.vmx") assert b.clone_linked("tpl.vmx", "snap", "name") is None # line 53 assert b.start(h) is None # line 57 assert b.stop(h) is None # line 61 assert b.delete(h) is None # line 65 assert b.get_ip(h) is None # line 69 assert b.list_snapshots(h) is None # line 73 assert b.is_running(h) is None # line 81