"""Unit tests for wizard state dataclasses."""

from __future__ import annotations

from tui.screens.template_build import BuildState
from tui.screens.vm_deploy import DeployState


class TestBuildState:
    """Tests for BuildState default values."""

    def test_defaults(self) -> None:
        s = BuildState()
        assert s.distro is None
        assert s.version is None
        assert s.profile == "base"
        assert s.network_mode == "dhcp"
        assert s.template_name is None
        assert s.template_id is None
        assert s.vm_cores == 2
        assert s.vm_memory == 2048
        assert s.vm_disk_size == "10G"
        assert s.cloudinit_user is None
        assert s.cloudinit_password is None

    def test_custom_values(self) -> None:
        s = BuildState(
            distro="ubuntu",
            version="24.04",
            profile="extended",
            vm_cores=4,
            vm_memory=8192,
        )
        assert s.distro == "ubuntu"
        assert s.version == "24.04"
        assert s.profile == "extended"
        assert s.vm_cores == 4
        assert s.vm_memory == 8192


class TestDeployState:
    """Tests for DeployState default values."""

    def test_defaults(self) -> None:
        s = DeployState()
        assert s.template_id is None
        assert s.template_name is None
        assert s.vm_id is None
        assert s.vm_name is None
        assert s.vm_cores == 2
        assert s.vm_memory == 2048
        assert s.vm_disk_size == "20G"
        assert s.network_mode == "dhcp"
        assert s.clone_type == "linked"
        assert s.playbooks == []

    def test_playbooks_not_shared(self) -> None:
        """Verify each instance gets its own playbooks list."""
        a = DeployState()
        b = DeployState()
        a.playbooks.append("nginx")
        assert b.playbooks == []

    def test_custom_values(self) -> None:
        s = DeployState(
            template_id=9200,
            vm_name="web-01",
            clone_type="full",
            playbooks=["nginx", "monitoring"],
        )
        assert s.template_id == 9200
        assert s.vm_name == "web-01"
        assert s.clone_type == "full"
        assert s.playbooks == ["nginx", "monitoring"]
