Chessistics/tools/automation/test_relocate.py

36 lines
961 B
Python
Raw Permalink Normal View History

"""End-to-end smoke test for piece relocation (drag & drop via IPC)."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from tools.automation.harness import Harness
def main():
with Harness.launch(run_name="relocate") as h:
h.load_mission("campaign_01", 0)
h.place("Pawn", (0, 0), (0, 1))
h.screenshot("01_placed")
s = h.state()
pid = s['pieces'][0]['id']
assert s['pieces'][0]['start'] == [0, 0]
assert s['pieces'][0]['end'] == [0, 1]
# Relocate pawn to (1,0)→(1,1) — vector preserved
r = h.relocate(pid, (1, 0), (1, 1))
print(f"[relocate] {r}")
assert r['relocated'], r
h.screenshot("02_relocated")
s = h.state()
assert s['pieces'][0]['start'] == [1, 0]
assert s['pieces'][0]['end'] == [1, 1]
print("OK — relocation works")
if __name__ == "__main__":
main()