def test_head_to_tail(graph): operations = graph.operations() solution = resolve(operations, {k: True for k in graph._nodes}, {k: k in graph._tails for k in graph._nodes}) assert solution is not None print('\n' + '\n'.join(map(str, solution)))
def test_tail_to_head(graph): operations = graph.operations() cstate = {k: k in graph._tails for k in graph._nodes} solution = resolve(operations, cstate, {k: True for k in graph.select('head')}) assert solution is not None print('\n' + '\n'.join(map(str, solution)))
def test_install_unistall(graph): operations = graph.operations(forward=False, rewind=False) ctx = Context() with compare_ctx(ctx): solution = resolve(operations, {k: False for k in graph._nodes}, {k: True for k in graph._nodes}) for op in solution: ctx.operation(op) solution = resolve(operations, {k: True for k in graph._nodes}, {k: False for k in graph._nodes}) print('\n'.join(map(str, solution))) for op in solution: ctx.operation(op)
def test_uninstall(graph): operations = graph.operations() cstate = {k: True for k in graph._nodes} tstate = {k: False for k in graph._nodes if k.revision == REVID_ZERO} s = resolve(operations, cstate, tstate) assert s is not None print('\n' + '\n'.join(map(str, s))) assert len(s) == 2 assert s[0].component == 'bar' and s[0].opname == 'uninstall' assert s[1].component == 'foo' and s[1].opname == 'uninstall'
def test_rewind(graph): ctx = Context().install() operations = graph.operations(install=False, forward=False, uninstall=False, rewind=True) solution = resolve(operations, {k: True for k in graph._nodes}, {k: k in graph._tails for k in graph._nodes}) print('\n'.join(map(str, solution))) for op in solution: ctx.operation(op) ref_dump = initial(Context()).dump() new_dump = ctx.dump() assert new_dump == ref_dump
def test_tail_to_head(graph): operations = graph.operations(rewind=False, install=False, uninstall=False) resolve( operations, {m: m in graph._tails for m in graph.select('all')}, {m: True for m in graph.select('head')})