fix(tests): use inventory store to interact with the inventory

This commit is contained in:
Johannes Kirschbauer
2025-05-23 21:46:35 +02:00
parent 4d9202551f
commit 0bf183b73b
3 changed files with 21 additions and 18 deletions

View File

@@ -54,6 +54,6 @@ def test_inventory_deserialize_variants(
assert "meta" in inventory
assert "machines" in inventory
assert "services" in inventory
assert "tags" in inventory
assert "modules" in inventory
# assert "tags" in inventory
# assert "modules" in inventory
assert "instances" in inventory

View File

@@ -9,11 +9,11 @@ from clan_lib.api.modules import list_modules
from clan_lib.flake import Flake
from clan_lib.nix import nix_eval, run
from clan_lib.nix_models.inventory import (
Inventory,
Machine,
MachineDeploy,
)
from clan_lib.persist.inventory_store import InventoryStore
from clan_lib.persist.util import apply_patch
if TYPE_CHECKING:
from .age_keys import KeyPair
@@ -72,9 +72,13 @@ def test_add_module_to_inventory(
)
subprocess.run(["git", "add", "."], cwd=test_flake_with_core.path, check=True)
inventory: Inventory = {}
inventory_store = InventoryStore(Flake(str(test_flake_with_core.path)))
inventory = inventory_store.read()
inventory["services"] = {
apply_patch(
inventory,
"services",
{
"borgbackup": {
"borg1": {
"meta": {"name": "borg1"},
@@ -84,9 +88,9 @@ def test_add_module_to_inventory(
},
}
}
}
},
)
inventory_store = InventoryStore(Flake(str(test_flake_with_core.path)))
inventory_store.write(
inventory,
message="Add borgbackup service",

View File

@@ -229,7 +229,6 @@ def generate_dataclass(
if len(attr_path) == 0 and prop not in attrs:
field_def = field_name, "dict[str, Any]"
fields_with_default.append(field_def)
# breakpoint()
continue
prop_type = prop_info.get("type", None)