规范了update data的构建方式,统一使用build_update_request_data方法来处理更新数据的构建和过滤逻辑。这个方法会根据提供的原始数据、更新数据和对应的schema来生成最终的更新请求数据,同时会自动排除掉未变化的字段和空值字段,从而确保只发送必要的更新信息到后端接口。这种方式不仅简化了代码逻辑,还提高了代码的可维护性和一致性。
This commit is contained in:
@@ -193,6 +193,30 @@ async def test_auto_binding_skip_on_ambiguous_migrated(setup_env):
|
||||
assert await bm.get_local_id("test_project", "r1") is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_auto_binding_many_to_one_can_bind_stable_pick_and_leave_rest_for_create(setup_env):
|
||||
local, remote, bm, _ = setup_env
|
||||
|
||||
strategy = TestProjectStrategy("test_project", local, remote, bm)
|
||||
strategy.update_config(
|
||||
auto_bind=True,
|
||||
auto_bind_fields=["code"],
|
||||
depend_fields={},
|
||||
local_orphan_action=OrphanAction.CREATE_REMOTE,
|
||||
allow_many_to_one_auto_bind=True,
|
||||
)
|
||||
|
||||
await local.add(build_project_node("l2", "P2", name="B", code="AMB-2"))
|
||||
await local.add(build_project_node("l1", "P1", name="A", code="AMB-2"))
|
||||
await remote.add(build_project_node("r1", "RP1", name="A", code="AMB-2"))
|
||||
|
||||
await strategy.bind()
|
||||
|
||||
assert await bm.get_remote_id("test_project", "l1") == "r1"
|
||||
assert await bm.get_remote_id("test_project", "l2") is None
|
||||
assert await bm.get_local_id("test_project", "r1") == "l1"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pre_bind_data_id_works_when_auto_bind_disabled(setup_env):
|
||||
local, remote, bm, _ = setup_env
|
||||
|
||||
Reference in New Issue
Block a user