From 0bf183b73b06d20df635e78f224e7aa511894fe6 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 23 May 2025 21:46:35 +0200 Subject: [PATCH] fix(tests): use inventory store to interact with the inventory --- .../clan_cli/tests/test_inventory_serde.py | 4 +-- pkgs/clan-cli/clan_cli/tests/test_modules.py | 34 +++++++++++-------- pkgs/classgen/main.py | 1 - 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/tests/test_inventory_serde.py b/pkgs/clan-cli/clan_cli/tests/test_inventory_serde.py index d181715d8..734bbef4c 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_inventory_serde.py +++ b/pkgs/clan-cli/clan_cli/tests/test_inventory_serde.py @@ -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 diff --git a/pkgs/clan-cli/clan_cli/tests/test_modules.py b/pkgs/clan-cli/clan_cli/tests/test_modules.py index d2a7fc903..dd7f2a20c 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_modules.py +++ b/pkgs/clan-cli/clan_cli/tests/test_modules.py @@ -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,21 +72,25 @@ def test_add_module_to_inventory( ) subprocess.run(["git", "add", "."], cwd=test_flake_with_core.path, check=True) - inventory: Inventory = {} - - inventory["services"] = { - "borgbackup": { - "borg1": { - "meta": {"name": "borg1"}, - "roles": { - "client": {"machines": ["machine1"]}, - "server": {"machines": ["machine1"]}, - }, - } - } - } - inventory_store = InventoryStore(Flake(str(test_flake_with_core.path))) + inventory = inventory_store.read() + + apply_patch( + inventory, + "services", + { + "borgbackup": { + "borg1": { + "meta": {"name": "borg1"}, + "roles": { + "client": {"machines": ["machine1"]}, + "server": {"machines": ["machine1"]}, + }, + } + } + }, + ) + inventory_store.write( inventory, message="Add borgbackup service", diff --git a/pkgs/classgen/main.py b/pkgs/classgen/main.py index 0f3004924..e8dac154e 100644 --- a/pkgs/classgen/main.py +++ b/pkgs/classgen/main.py @@ -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)