修改多个问题,优化代码结构
This commit is contained in:
@@ -100,9 +100,11 @@ async def test_core_binding_matrix_migrated(
|
||||
await bm.bind("test_project", f"{name}_l", f"{name}_r")
|
||||
|
||||
await phase_core_state(
|
||||
strategy,
|
||||
local.filter(node_type="test_project"),
|
||||
remote.filter(node_type="test_project"),
|
||||
node_type=strategy.node_type,
|
||||
runtime=strategy.ensure_runtime(),
|
||||
binding_manager=bm,
|
||||
local_nodes=local.filter(node_type="test_project"),
|
||||
remote_nodes=remote.filter(node_type="test_project"),
|
||||
)
|
||||
|
||||
if expected_local is not None:
|
||||
@@ -123,9 +125,11 @@ async def test_dependency_resolution_migrated(setup_env):
|
||||
await bm.bind("test_project", "proj_l", "proj_r")
|
||||
|
||||
await phase_core_state(
|
||||
project_strategy,
|
||||
local.filter(node_type="test_project"),
|
||||
remote.filter(node_type="test_project"),
|
||||
node_type=project_strategy.node_type,
|
||||
runtime=project_strategy.ensure_runtime(),
|
||||
binding_manager=bm,
|
||||
local_nodes=local.filter(node_type="test_project"),
|
||||
remote_nodes=remote.filter(node_type="test_project"),
|
||||
)
|
||||
assert local.get("proj_l").binding_status == BindingStatus.NORMAL
|
||||
|
||||
@@ -159,8 +163,22 @@ async def test_dependency_resolution_migrated(setup_env):
|
||||
|
||||
local_contracts = local.filter(node_type="test_contract")
|
||||
remote_contracts = remote.filter(node_type="test_contract")
|
||||
await phase_core_state(contract_strategy, local_contracts, remote_contracts)
|
||||
await phase_dependency_check(contract_strategy, local_contracts, remote_contracts)
|
||||
await phase_core_state(
|
||||
node_type=contract_strategy.node_type,
|
||||
runtime=contract_strategy.ensure_runtime(),
|
||||
binding_manager=bm,
|
||||
local_nodes=local_contracts,
|
||||
remote_nodes=remote_contracts,
|
||||
)
|
||||
await phase_dependency_check(
|
||||
node_type=contract_strategy.node_type,
|
||||
runtime=contract_strategy.ensure_runtime(),
|
||||
depend_fields=dict(contract_strategy.config.depend_fields),
|
||||
local_nodes=local_contracts,
|
||||
remote_nodes=remote_contracts,
|
||||
local_collection=local,
|
||||
remote_collection=remote,
|
||||
)
|
||||
|
||||
assert local.get("contract_ok").binding_status == BindingStatus.MISSING
|
||||
assert local.get("contract_ok").depend_ids == ["proj_l"]
|
||||
@@ -269,8 +287,22 @@ async def test_dependency_check_data_missing_goes_abnormal(setup_env):
|
||||
)
|
||||
|
||||
local_contracts = local.filter(node_type="test_contract")
|
||||
await phase_core_state(strategy, local_contracts, [])
|
||||
await phase_dependency_check(strategy, local_contracts, [])
|
||||
await phase_core_state(
|
||||
node_type=strategy.node_type,
|
||||
runtime=strategy.ensure_runtime(),
|
||||
binding_manager=bm,
|
||||
local_nodes=local_contracts,
|
||||
remote_nodes=[],
|
||||
)
|
||||
await phase_dependency_check(
|
||||
node_type=strategy.node_type,
|
||||
runtime=strategy.ensure_runtime(),
|
||||
depend_fields=dict(strategy.config.depend_fields),
|
||||
local_nodes=local_contracts,
|
||||
remote_nodes=[],
|
||||
local_collection=local,
|
||||
remote_collection=remote,
|
||||
)
|
||||
|
||||
assert local.get("contract_no_data").binding_status == BindingStatus.ABNORMAL
|
||||
|
||||
@@ -306,8 +338,31 @@ async def test_auto_binding_key_id_resolve_fail_migrated(setup_env):
|
||||
await local.add(build_project_node("kid_l", "KID-L", name="KID", code="KID-1"))
|
||||
|
||||
local_nodes = local.filter(node_type="test_project")
|
||||
await phase_core_state(strategy, local_nodes, [])
|
||||
await phase_auto_binding(strategy, local_nodes, [])
|
||||
await phase_core_state(
|
||||
node_type=strategy.node_type,
|
||||
runtime=strategy.ensure_runtime(),
|
||||
binding_manager=bm,
|
||||
local_nodes=local_nodes,
|
||||
remote_nodes=[],
|
||||
)
|
||||
local_flags = {
|
||||
node.node_id: strategy.config.local_orphan_action == OrphanAction.CREATE_REMOTE
|
||||
for node in local_nodes
|
||||
}
|
||||
remote_flags = {}
|
||||
await phase_auto_binding(
|
||||
node_type=strategy.node_type,
|
||||
runtime=strategy.ensure_runtime(),
|
||||
config=strategy.config,
|
||||
local_collection=local,
|
||||
remote_collection=remote,
|
||||
binding_manager=bm,
|
||||
local_nodes=local_nodes,
|
||||
remote_nodes=[],
|
||||
id_field_hints=dict(strategy.config.depend_fields),
|
||||
local_orphan_create_enabled_by_node=local_flags,
|
||||
remote_orphan_create_enabled_by_node=remote_flags,
|
||||
)
|
||||
|
||||
node = local.get("kid_l")
|
||||
assert node.binding_status == BindingStatus.DEPENDENCY_ERROR
|
||||
|
||||
Reference in New Issue
Block a user