clan-cli: Fix some type errors in tests

This commit is contained in:
Qubasa
2024-08-21 15:48:26 +02:00
parent 1cb26b41e7
commit 6c4d7494f6
6 changed files with 24 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Literal from typing import Any, Literal
import pytest import pytest
@@ -128,7 +128,7 @@ def test_simple_field_missing() -> None:
class Person: class Person:
name: str name: str
person_dict = {} person_dict: Any = {}
with pytest.raises(ClanError): with pytest.raises(ClanError):
from_dict(Person, person_dict) from_dict(Person, person_dict)
@@ -151,7 +151,7 @@ def test_nullable_non_exist() -> None:
class Person: class Person:
name: None name: None
person_dict = {} person_dict: Any = {}
with pytest.raises(ClanError): with pytest.raises(ClanError):
from_dict(Person, person_dict) from_dict(Person, person_dict)

View File

@@ -61,7 +61,7 @@ def test_add_module_to_inventory(
] ]
) )
create_machine( create_machine(
FlakeId(base_path), FlakeId(str(base_path)),
Machine( Machine(
name="machine1", tags=[], system="x86_64-linux", deploy=MachineDeploy() name="machine1", tags=[], system="x86_64-linux", deploy=MachineDeploy()
), ),

View File

@@ -48,7 +48,9 @@ def test_generate_secret(
) )
cmd = ["facts", "generate", "--flake", str(test_flake_with_core.path), "vm1"] cmd = ["facts", "generate", "--flake", str(test_flake_with_core.path), "vm1"]
cli.run(cmd) cli.run(cmd)
store1 = SecretStore(Machine(name="vm1", flake=FlakeId(test_flake_with_core.path))) store1 = SecretStore(
Machine(name="vm1", flake=FlakeId(str(test_flake_with_core.path)))
)
assert store1.exists("", "age.key") assert store1.exists("", "age.key")
assert store1.exists("", "zerotier-identity-secret") assert store1.exists("", "zerotier-identity-secret")

View File

@@ -4,17 +4,17 @@ from pathlib import Path
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
import pytest import pytest
from age_keys import SopsSetup
from fixtures_flakes import generate_flake
from helpers import cli
from helpers.nixos_config import nested_dict
from root import CLAN_CORE
from clan_cli.clan_uri import FlakeId from clan_cli.clan_uri import FlakeId
from clan_cli.machines.machines import Machine from clan_cli.machines.machines import Machine
from clan_cli.nix import nix_shell from clan_cli.nix import nix_shell
from clan_cli.vars.public_modules import in_repo from clan_cli.vars.public_modules import in_repo
from clan_cli.vars.secret_modules import password_store, sops from clan_cli.vars.secret_modules import password_store, sops
from tests.age_keys import SopsSetup
from tests.fixtures_flakes import generate_flake
from tests.helpers import cli
from tests.helpers.nixos_config import nested_dict
from tests.root import CLAN_CORE
def test_get_subgraph() -> None: def test_get_subgraph() -> None:

View File

@@ -1,13 +1,12 @@
from pathlib import Path from pathlib import Path
import pytest import pytest
from age_keys import SopsSetup
from tests.age_keys import SopsSetup from fixtures_flakes import generate_flake
from tests.fixtures_flakes import generate_flake from helpers import cli
from tests.helpers import cli from helpers.nixos_config import nested_dict
from tests.helpers.nixos_config import nested_dict from helpers.vms import qga_connect, run_vm_in_thread, wait_vm_down
from tests.helpers.vms import qga_connect, run_vm_in_thread, wait_vm_down from root import CLAN_CORE
from tests.root import CLAN_CORE
@pytest.mark.impure @pytest.mark.impure

View File

@@ -3,16 +3,15 @@ from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import pytest import pytest
from fixtures_flakes import FlakeForTest, generate_flake
from helpers import cli
from helpers.nixos_config import nested_dict
from helpers.vms import qga_connect, qmp_connect, run_vm_in_thread, wait_vm_down
from root import CLAN_CORE
from stdout import CaptureOutput from stdout import CaptureOutput
from tests.fixtures_flakes import FlakeForTest, generate_flake
from tests.helpers import cli
from tests.helpers.nixos_config import nested_dict
from tests.helpers.vms import qga_connect, qmp_connect, run_vm_in_thread, wait_vm_down
from tests.root import CLAN_CORE
if TYPE_CHECKING: if TYPE_CHECKING:
from tests.age_keys import KeyPair from age_keys import KeyPair
no_kvm = not os.path.exists("/dev/kvm") no_kvm = not os.path.exists("/dev/kvm")