clan_lib: disable static checks temporarily
This commit is contained in:
@@ -6,8 +6,6 @@ from clan_lib.persist.path_utils import (
|
||||
PathTuple,
|
||||
flatten_data_structured,
|
||||
list_difference,
|
||||
path_starts_with,
|
||||
path_to_string,
|
||||
should_skip_path,
|
||||
)
|
||||
from clan_lib.persist.validate import (
|
||||
@@ -127,11 +125,12 @@ def calc_patches(
|
||||
delete_paths = find_deleted_paths_structured(all_values, update)
|
||||
|
||||
# Validate deletions don't affect static data
|
||||
for delete_path in delete_paths:
|
||||
for static_path in static_data:
|
||||
if path_starts_with(static_path, delete_path):
|
||||
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)
|
||||
# TODO: We currently cannot validate this properly.
|
||||
# for delete_path in delete_paths:
|
||||
# for static_path in static_data:
|
||||
# if path_starts_with(static_path, delete_path):
|
||||
# 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
|
||||
all_paths: set[PathTuple] = set(all_values_flat) | set(update_flat)
|
||||
|
||||
@@ -73,6 +73,49 @@ def test_calculate_static_data_no_static() -> None:
|
||||
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:
|
||||
all_values = {
|
||||
"name": "example",
|
||||
@@ -327,30 +370,31 @@ def test_update_parent_non_writeable() -> None:
|
||||
assert "Path 'foo.bar' is readonly." in str(error.value)
|
||||
|
||||
|
||||
def test_remove_non_writable_attrs() -> None:
|
||||
prios = {
|
||||
"foo": {
|
||||
"__prio": 100, # <- writeable: "foo"
|
||||
},
|
||||
}
|
||||
# TODO: Resolve the issue https://git.clan.lol/clan/clan-core/issues/5231
|
||||
# def test_remove_non_writable_attrs() -> None:
|
||||
# prios = {
|
||||
# "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 = {
|
||||
"foo": {
|
||||
"bar": {}, # <- user leaves this value
|
||||
# User removed "baz"
|
||||
},
|
||||
}
|
||||
# update: dict = {
|
||||
# "foo": {
|
||||
# "bar": {}, # <- user leaves this value
|
||||
# # User removed "baz"
|
||||
# },
|
||||
# }
|
||||
|
||||
with pytest.raises(ClanError) as error:
|
||||
calc_patches(data_disk, update, all_values=data_eval, writeables=writeables)
|
||||
# with pytest.raises(ClanError) as error:
|
||||
# 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:
|
||||
|
||||
Reference in New Issue
Block a user