1"""One drawing, one vehicle.
3pid-designer's Duplicate page is offered for "another version of the same stand
4-- the hotfire and the launch configuration". It keeps every tag, and its
5duplicate-tag check is per page, so the copy passes there. The twin builds every
6page into one network: LE4 with its Rocket page duplicated built as two rockets
7sharing seven signals, no valve bound, and Fire sat at 0 N with no message.
10from __future__
import annotations
14from pathlib
import Path
23DRAWING = Path(__file__).resolve().parent /
"fixtures" /
"le4_rocket_and_gse.json"
27 return json.loads(DRAWING.read_text())
30def _duplicated(page: str =
"Rocket", copy_name: str =
"Rocket (copy)") -> Any:
31 """``page`` copied as duplicatePage does: fresh ids, tags kept, pairs and
32 clips inside the page remapped."""
34 on = {n[
"id"]
for n
in payload[
"nodes"]
if n[
"data"].get(
"page") == page}
35 fresh = {i: f
"{i}_copy" for i
in on}
37 for node
in payload[
"nodes"]:
38 if node[
"id"]
not in on:
40 twin = copy.deepcopy(node)
41 twin[
"id"] = fresh[node[
"id"]]
42 twin[
"data"][
"page"] = copy_name
43 options = twin[
"data"].get(
"options")
or {}
44 if options.get(
"pairedWith")
in fresh:
45 options[
"pairedWith"] = fresh[options[
"pairedWith"]]
46 if twin[
"data"].get(
"attachedTo")
in fresh:
47 twin[
"data"][
"attachedTo"] = fresh[twin[
"data"][
"attachedTo"]]
49 for edge
in payload[
"edges"]:
50 if edge[
"source"]
in on
and edge[
"target"]
in on:
51 twin = copy.deepcopy(edge)
52 twin[
"id"] = f
"{edge['id']}_copy"
53 twin[
"source"], twin[
"target"] = (
54 fresh[edge[
"source"]],
55 fresh[edge[
"target"]],
58 payload[
"nodes"] += nodes
59 payload[
"edges"] += edges
63@pytest.mark.parametrize("cut", [False, True])
65 diagram = read_diagram(
_duplicated(), name=
"LE4 (6)")
66 with pytest.raises(AssemblyError)
as refused:
67 assemble_model(diagram, diagram_id=
"le4", vehicle_only=cut)
68 said = str(refused.value)
69 assert "2 separate vehicles" in said
70 assert "page Rocket" in said
and "page Rocket (copy)" in said
74 built = build_network(read_diagram(
_payload(), name=
"LE4 (6)"))
75 assert not [w
for w
in built.warnings
if "is the tag of" in w]
79 """A copied cart page has one engine, so it builds -- and the solenoids it
80 copied answer one signal between them, which is worth a line."""
82 built = build_network(read_diagram(payload, name=
"LE4 (6)"))
83 shared = [w
for w
in built.warnings
if "is the tag of 2 valves" in w]
84 assert shared, built.warnings
85 assert any(
"GSE and GSE (copy)" in w
for w
in shared)
None test_two_versions_of_the_rocket_are_refused_and_the_pages_named(bool cut)
None test_the_drawing_with_one_rocket_builds()
Any _duplicated(str page="Rocket", str copy_name="Rocket (copy)")
None test_a_tag_two_driven_valves_share_is_said()