34 lines
997 B
Python
34 lines
997 B
Python
"""Cumulative synthesis chain: newest does not mean only."""
|
|
|
|
from rune.orchestration.chain import SynthesisChain
|
|
|
|
|
|
def test_append_links_to_previous():
|
|
chain = SynthesisChain()
|
|
n1 = chain.append("out1", "sha256:a")
|
|
n2 = chain.append("out2", "sha256:b")
|
|
assert chain.newest().node_id == n2.node_id
|
|
assert n2.parent_id == n1.node_id
|
|
|
|
|
|
def test_ancestors_walk_cumulative_chain():
|
|
chain = SynthesisChain()
|
|
chain.append("out1", "sha256:a")
|
|
chain.append("out2", "sha256:b")
|
|
chain.append("out3", "sha256:c")
|
|
anc = chain.ancestors()
|
|
assert [n.output_id for n in anc] == ["out3", "out2", "out1"]
|
|
|
|
|
|
def test_get_returns_node_or_none():
|
|
chain = SynthesisChain()
|
|
n = chain.append("out1", "sha256:a")
|
|
assert chain.get(n.node_id).output_id == "out1"
|
|
assert chain.get("missing") is None
|
|
|
|
|
|
def test_empty_chain_returns_none_newest_and_empty_ancestors():
|
|
chain = SynthesisChain()
|
|
assert chain.newest() is None
|
|
assert chain.ancestors() == []
|