def create_decision_item(action=None,
                         common_path="",
                         conflict=False,
                         local_diff=None,
                         remote_diff=None,
                         custom_diff=None):

    # Some parameter validation here, but don't need to duplicate json schema
    if action is None:
        pass
    elif action == "local":
        assert local_diff
    elif action == "remote":
        assert remote_diff
    elif action == "custom":
        assert custom_diff
    elif action in ("either", "local_then_remote", "remote_then_local"):
        assert local_diff
        assert remote_diff
    else:
        pass

    item = MergeDecision({
        "action": action,
        "common_path": common_path,
        "conflict": conflict,
        "custom_diff": custom_diff,
        "local_diff": local_diff,
        "remote_diff": remote_diff,
    })
    return item
Ejemplo n.º 2
0
def test_pop_patch_unpoppable():
    md = MergeDecision(common_path=("a", "b"),
                       action="base",
                       conflict=True,
                       local_diff=[op_remove("c")],
                       remote_diff=[op_patch("c", [op_remove("d")])])
    dec = pop_patch_decision(md)
    assert dec is None
Ejemplo n.º 3
0
def test_pop_patch_single_level():
    md = MergeDecision(common_path=("a", "b"),
                       action="base",
                       conflict=True,
                       local_diff=[op_patch("c", [op_remove("d")])],
                       remote_diff=[op_patch("c", [op_remove("e")])])
    dec = pop_patch_decision(md)
    assert dec is not None
    assert dec.common_path == ("a", "b", "c")
    assert dec.local_diff == [op_remove("d")]
    assert dec.remote_diff == [op_remove("e")]