clan_lib: disable static checks temporarily

This commit is contained in:
Johannes Kirschbauer
2025-09-22 18:26:33 +02:00
parent 3574b37a29
commit 9ea5156f32
2 changed files with 68 additions and 25 deletions

View File

@@ -6,8 +6,6 @@ from clan_lib.persist.path_utils import (
PathTuple, PathTuple,
flatten_data_structured, flatten_data_structured,
list_difference, list_difference,
path_starts_with,
path_to_string,
should_skip_path, should_skip_path,
) )
from clan_lib.persist.validate import ( from clan_lib.persist.validate import (
@@ -127,11 +125,12 @@ def calc_patches(
delete_paths = find_deleted_paths_structured(all_values, update) delete_paths = find_deleted_paths_structured(all_values, update)
# Validate deletions don't affect static data # Validate deletions don't affect static data
for delete_path in delete_paths: # TODO: We currently cannot validate this properly.
for static_path in static_data: # for delete_path in delete_paths:
if path_starts_with(static_path, delete_path): # for static_path in static_data:
msg = f"Cannot delete path '{path_to_string(delete_path)}' - Readonly path '{path_to_string(static_path)}' is set via .nix file" # if path_starts_with(static_path, delete_path):
raise ClanError(msg) # msg = f"Cannot delete path '{path_to_string(delete_path)}' - Readonly path '{path_to_string(static_path)}' is set via .nix file"
# raise ClanError(msg)
# Get all paths that might need processing # Get all paths that might need processing
all_paths: set[PathTuple] = set(all_values_flat) | set(update_flat) all_paths: set[PathTuple] = set(all_values_flat) | set(update_flat)

View File

@@ -73,6 +73,49 @@ def test_calculate_static_data_no_static() -> None:
assert static_data == expected_static assert static_data == expected_static
# See: https://git.clan.lol/clan/clan-core/issues/5231
# Uncomment this test if the issue is resolved
# def test_calculate_static_data_no_static_sets() -> None:
# all_values = {
# "instance": {
# "hello": {
# "roles": {
# "default": {
# "machines": {
# "jon": {
# # Default
# "settings": {
# }
# }
# }
# }
# }
# }
# }
# }
# persisted = {
# "instance": {
# "hello": {
# "roles": {
# "default": {
# "machines": {
# "jon": {
# }
# }
# }
# }
# }
# }
# }
# expected_static: dict = {}
# static_data = calculate_static_data(all_values, persisted)
# assert static_data == expected_static
def test_calculate_static_data_all_static() -> None: def test_calculate_static_data_all_static() -> None:
all_values = { all_values = {
"name": "example", "name": "example",
@@ -327,30 +370,31 @@ def test_update_parent_non_writeable() -> None:
assert "Path 'foo.bar' is readonly." in str(error.value) assert "Path 'foo.bar' is readonly." in str(error.value)
def test_remove_non_writable_attrs() -> None: # TODO: Resolve the issue https://git.clan.lol/clan/clan-core/issues/5231
prios = { # def test_remove_non_writable_attrs() -> None:
"foo": { # prios = {
"__prio": 100, # <- writeable: "foo" # "foo": {
}, # "__prio": 100, # <- writeable: "foo"
} # },
# }
data_eval: dict = {"foo": {"bar": {}, "baz": {}}} # data_eval: dict = {"foo": {"bar": {}, "baz": {}}}
data_disk: dict = {} # data_disk: dict = {}
writeables = compute_write_map(prios, data_eval, data_disk) # writeables = compute_write_map(prios, data_eval, data_disk)
update: dict = { # update: dict = {
"foo": { # "foo": {
"bar": {}, # <- user leaves this value # "bar": {}, # <- user leaves this value
# User removed "baz" # # User removed "baz"
}, # },
} # }
with pytest.raises(ClanError) as error: # with pytest.raises(ClanError) as error:
calc_patches(data_disk, update, all_values=data_eval, writeables=writeables) # calc_patches(data_disk, update, all_values=data_eval, writeables=writeables)
assert "Cannot delete path 'foo.baz'" in str(error.value) # assert "Cannot delete path 'foo.baz'" in str(error.value)
def test_update_list() -> None: def test_update_list() -> None: