clan_lib: fix inventory test message assertions
This commit is contained in:
@@ -124,10 +124,7 @@ def test_create_cannot_set_name(tmp_path: Path, offline_flake_hook: Any) -> None
|
||||
with pytest.raises(ClanError) as exc_info:
|
||||
create_clan(opts)
|
||||
|
||||
assert (
|
||||
"Key 'meta.name' is not writeable. It seems its value is statically defined in nix."
|
||||
in str(exc_info.value)
|
||||
)
|
||||
assert "Path 'meta.name' is readonly" in str(exc_info.value)
|
||||
|
||||
|
||||
@pytest.mark.with_core
|
||||
|
||||
@@ -164,10 +164,7 @@ def test_set_machine_fully_defined_in_nix(clan_flake: Callable[..., Flake]) -> N
|
||||
with pytest.raises(ClanError) as exc_info:
|
||||
set_machine(Machine("jon", flake), machine_jon)
|
||||
|
||||
assert (
|
||||
"Key 'machines.jon.description' is not writeable. It seems its value is statically defined in nix."
|
||||
in str(exc_info.value)
|
||||
)
|
||||
assert "Path 'machines.jon.description' is readonly" in str(exc_info.value)
|
||||
|
||||
# Assert _write should not be called
|
||||
mock_write.assert_not_called()
|
||||
@@ -213,8 +210,11 @@ def test_set_machine_manage_tags(clan_flake: Callable[..., Flake]) -> None:
|
||||
with pytest.raises(ClanError) as exc_info:
|
||||
set_jon(invalid_tags)
|
||||
|
||||
assert "Key 'machines.jon.tags' doesn't contain items ['nix1', 'nix2']" in str(
|
||||
exc_info.value,
|
||||
assert (
|
||||
"Path 'machines.jon.tags' doesn't contain static items ['nix1', 'nix2']"
|
||||
in str(
|
||||
exc_info.value,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -120,10 +120,7 @@ def test_simple_read_write(setup_test_files: Path) -> None:
|
||||
invalid_data = {"protected": "foo"}
|
||||
with pytest.raises(ClanError) as e:
|
||||
store.write(invalid_data, "test", commit=False) # type: ignore[arg-type]
|
||||
assert (
|
||||
str(e.value)
|
||||
== "Key 'protected' is not writeable. It seems its value is statically defined in nix."
|
||||
)
|
||||
assert "Path 'protected' is readonly" in str(e.value)
|
||||
|
||||
# Test the data is not touched
|
||||
assert store.read() == data
|
||||
@@ -255,10 +252,7 @@ def test_manipulate_list(setup_test_files: Path) -> None:
|
||||
|
||||
with pytest.raises(ClanError) as e:
|
||||
store.write(data, "test", commit=False)
|
||||
assert (
|
||||
str(e.value)
|
||||
== "Key 'empty' contains list duplicates: ['a'] - List values must be unique."
|
||||
)
|
||||
assert "Path 'empty' contains list duplicates: ['a']" in str(e.value)
|
||||
|
||||
assert store.read() == {"empty": [], "predefined": ["a", "b"]}
|
||||
|
||||
@@ -287,7 +281,4 @@ def test_static_list_items(setup_test_files: Path) -> None:
|
||||
with pytest.raises(ClanError) as e:
|
||||
store.write(data, "test", commit=False)
|
||||
|
||||
assert (
|
||||
str(e.value)
|
||||
== "Key 'predefined' doesn't contain items ['a'] - Deleting them is not possible, they are static values set via a .nix file"
|
||||
)
|
||||
assert "Path 'predefined' doesn't contain static items ['a']" in str(e.value)
|
||||
|
||||
Reference in New Issue
Block a user