Refactor: replace direct references to inventory
Deprecated. Inventory should be accessed via InventoryStore {read(),write(),...}
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
import pytest
|
||||
from clan_cli.flake import Flake
|
||||
|
||||
# Functions to test
|
||||
from clan_cli.inventory import load_inventory_eval
|
||||
from clan_cli.tests.fixtures_flakes import FlakeForTest
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -44,7 +42,11 @@ def test_inventory_deserialize_variants(
|
||||
Testing different inventory deserializations
|
||||
Inventory should always be deserializable to a dict
|
||||
"""
|
||||
inventory: dict[str, Any] = load_inventory_eval(Flake(test_flake_with_core.path)) # type: ignore
|
||||
inventory_store = InventoryStore(Flake(str(test_flake_with_core.path)))
|
||||
|
||||
# Cast the inventory to a dict for the following assertions
|
||||
inventory = cast(dict[str, Any], inventory_store.read())
|
||||
|
||||
# Check that the inventory is a dict
|
||||
assert isinstance(inventory, dict)
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from clan_cli.flake import Flake
|
||||
from clan_cli.inventory import (
|
||||
set_inventory,
|
||||
)
|
||||
from clan_cli.machines.create import CreateOptions, create_machine
|
||||
from clan_cli.nix import nix_eval, run
|
||||
from clan_cli.tests.fixtures_flakes import FlakeForTest
|
||||
@@ -16,6 +13,7 @@ from clan_lib.nix_models.inventory import (
|
||||
Machine,
|
||||
MachineDeploy,
|
||||
)
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .age_keys import KeyPair
|
||||
@@ -88,7 +86,12 @@ def test_add_module_to_inventory(
|
||||
}
|
||||
}
|
||||
|
||||
set_inventory(inventory, Flake(str(base_path)), "Add borgbackup service")
|
||||
inventory_store = InventoryStore(Flake(str(test_flake_with_core.path)))
|
||||
inventory_store.write(
|
||||
inventory,
|
||||
message="Add borgbackup service",
|
||||
commit=False,
|
||||
)
|
||||
|
||||
# cmd = ["facts", "generate", "--flake", str(test_flake_with_core.path), "machine1"]
|
||||
cmd = [
|
||||
|
||||
Reference in New Issue
Block a user