drawings: on a rev mismatch, Clerical can keep the retired rev VISUAL calls (#41)
When VISUAL calls a rev that M-Files has retired, the draft is still flagged rev_mismatch, but the drawing job now also copies the rev VISUAL calls (MFilesKit 0.1.3 DrawingLookup.revision) into drawing_revisions and visual.called. A Clerical Supervisor picks either rev on the packet: "Use latest rev N" as before, or "Use rev V as VISUAL calls it" (rev-approve with use=called), with a reason and a signature. The kept rev holds while M-Files' Effective rev stays the one chosen against: no flag, no change order. A newer Effective rev flags the packet again; a new VISUAL rev clears the choice. Migration 0009 adds drawing_revisions. Needs mfileskit 0.1.3. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -19,7 +19,7 @@ from feedhelpers import (
|
||||
)
|
||||
from pshelpers import app_conn, needs_pg
|
||||
|
||||
from packetstation.drawings.decide import Decision, Target, decide
|
||||
from packetstation.drawings.decide import Decision, Target, decide, rev_confirmed
|
||||
from packetstation.drawings.fake import FixtureLookup
|
||||
from packetstation.drawings.lookup import Found
|
||||
from packetstation.settings import Settings
|
||||
@@ -129,6 +129,26 @@ def test_approved_other_rev_still_mismatches() -> None:
|
||||
assert d(target(visual_rev="2", rev_ok="4"), found(rev=3)).kind == "rev_mismatch"
|
||||
|
||||
|
||||
def test_kept_called_rev_stays_while_the_effective_rev_is_the_same() -> None:
|
||||
t = target(visual_rev="2", drawing_state="attached", attached_rev="2", kept_latest="3")
|
||||
r = d(t, found(rev=3))
|
||||
assert (r.kind, r.flag, r.drawing_state) == ("unchanged", None, "attached")
|
||||
assert r.note == "Rev 2 kept by Clerical; M-Files has rev 3"
|
||||
assert rev_confirmed(t, found(rev=3))
|
||||
|
||||
|
||||
def test_kept_called_rev_opens_no_change_order_past_draft() -> None:
|
||||
t = target(visual_rev="2", status="ready", drawing_state="attached", attached_rev="2", kept_latest="3")
|
||||
assert d(t, found(rev=3)).kind == "unchanged"
|
||||
|
||||
|
||||
def test_kept_called_rev_flags_again_on_a_newer_effective_rev() -> None:
|
||||
t = target(visual_rev="2", drawing_state="attached", attached_rev="2", kept_latest="3")
|
||||
r = d(t, found(rev=4))
|
||||
assert (r.kind, r.flag, r.drawing_state) == ("rev_mismatch", "rev_mismatch", "attached")
|
||||
assert not rev_confirmed(t, found(rev=4))
|
||||
|
||||
|
||||
def test_match_on_a_draft_attaches() -> None:
|
||||
r = d(target(), found())
|
||||
assert (r.kind, r.flag, r.drawing_state) == ("attach", None, "attached")
|
||||
@@ -193,6 +213,11 @@ def test_fixture_lookup_states(tmp_path: Path) -> None:
|
||||
assert one.status("L900-0701").rev is None and one.status("L900-0701").ok
|
||||
dest = tmp_path / "out" / "x.pdf"
|
||||
assert one.download(one.status("L900-0101"), dest) > 0 and dest.read_bytes().startswith(b"%PDF-")
|
||||
r2 = one.revision("L900-0201", 2)
|
||||
assert r2 is not None and (r2.rev, r2.controlled, r2.effective) == (2, "Retired", False)
|
||||
assert one.revision("L900-0201", 9) is None and one.revision("L900-0101", 1) is None
|
||||
dest2 = tmp_path / "out" / "r2.pdf"
|
||||
assert one.download(r2, dest2) > 0 and dest2.read_bytes() != dest.read_bytes()
|
||||
(tmp_path / "state").write_text("2")
|
||||
two = FixtureLookup(tmp_path)
|
||||
f2 = two.status("L900-0101")
|
||||
@@ -249,6 +274,17 @@ def test_job_attaches_and_flags(fx: Settings) -> None:
|
||||
).fetchone()
|
||||
assert staged == (True, 3) # staged for Clerical Supervisor approval
|
||||
assert _drawing_pages(conn, mm["id"]) == []
|
||||
called = mm["visual"]["called"] # VISUAL's rev 2, Retired in M-Files, copied for Clerical's choice
|
||||
assert (called["rev"], called["controlled"], called["state"]) == ("2", "Retired", "Superseded")
|
||||
assert called["asset_id"] and called["pages"] >= 1
|
||||
rv = conn.execute(
|
||||
"SELECT controlled, asset_id IS NOT NULL FROM drawing_revisions WHERE dwg = 'L900-0201' AND rev = 2"
|
||||
).fetchone()
|
||||
assert rv == ("Retired", True)
|
||||
assert conn.execute(
|
||||
"SELECT count(*) FROM packet_log WHERE packet_id = %s AND note LIKE %s",
|
||||
(mm["id"], "%rev 2 is Retired in M-Files%"),
|
||||
).fetchone()[0]
|
||||
|
||||
nr = packet_by_key(conn, gen.KEY_DRAFTING)
|
||||
assert nr is not None and "not_released" in nr["flags"] and nr["drawing_state"] == "not_released"
|
||||
|
||||
Reference in New Issue
Block a user