42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from sync_state_machine.config.builder import _apply_strategy_overrides
|
|
from sync_state_machine.config.strategy_config import StrategyConfig, StrategyRuntimeConfig
|
|
|
|
|
|
def test_strategy_runtime_config_skip_sync_defaults_false() -> None:
|
|
runtime_config = StrategyRuntimeConfig(node_type="project")
|
|
|
|
assert runtime_config.skip_sync is False
|
|
assert runtime_config.skip_post_check is False
|
|
|
|
|
|
def test_apply_strategy_overrides_allows_skip_sync_override() -> None:
|
|
resolved = _apply_strategy_overrides(
|
|
node_types=["project"],
|
|
strategy_overrides={
|
|
"project": {
|
|
"skip_sync": True,
|
|
"skip_post_check": True,
|
|
}
|
|
},
|
|
)
|
|
|
|
assert len(resolved) == 1
|
|
assert resolved[0].node_type == "project"
|
|
assert resolved[0].skip_sync is True
|
|
assert resolved[0].skip_post_check is True
|
|
|
|
|
|
def test_strategy_config_supports_both_post_check_ignore_fields() -> None:
|
|
config = StrategyConfig.model_validate(
|
|
{
|
|
"post_check_ignore_fields": ["code"],
|
|
"post_check_ignore_list_item_fields": {"plan_node": ["is_audit"]},
|
|
"allow_many_to_one_auto_bind": True,
|
|
}
|
|
)
|
|
|
|
assert config.post_check_ignore_fields == ["code"]
|
|
assert config.post_check_ignore_list_item_fields == {"plan_node": ["is_audit"]}
|
|
assert config.allow_many_to_one_auto_bind is True |