by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
main
Colby Knox
0.2.99: dashboard picks a Windows machine only on a click, Works here section with a Linux Altium 365 bridge (#33)
687f09e
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
"""The dashboard's machine rule (altium-bridge#33): never drive a machine the user did not choose.
Run: python3 dev-skills/altium-bridge-test/test_dashboard_machines.py
"""
import os
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dashboard"))
import machines # noqa: E402
TARGETS = {"targets": [
{"name": "AdomLapper", "hostname": "AdomLapper", "os": "Windows", "reachable": True},
{"name": "arav-rog", "hostname": "ARAV-ROG", "os": "Windows", "reachable": "mesh"},
{"name": "m5-ubuntu", "hostname": "m5-ubuntu", "os": "Linux", "reachable": True},
{"name": "winvm", "hostname": "winvm", "os": None, "reachable": "mesh"},
{"name": "old-pc", "hostname": "old-pc", "os": "Windows", "reachable": False},
]}
class MachineRule(unittest.TestCase):
def setUp(self):
os.environ.pop("ADOM_ALTIUM_DASHBOARD_LOCAL_OS", None)
self.rows = machines.rows_from_targets(TARGETS)
def test_linux_with_no_pick_drives_nothing(self):
self.assertEqual(machines.choose(None, self.rows, "m5-ubuntu", None), (None, "no_machine_picked"))
self.assertEqual(machines.choose("-", self.rows, "m5-ubuntu", None), (None, "no_machine_picked"))
def test_the_picker_lists_reachable_windows_machines_only(self):
p = machines.picker_payload(self.rows, "m5-ubuntu")
self.assertEqual([m["name"] for m in p["windowsMachines"]], ["AdomLapper", "arav-rog"])
self.assertEqual(p["windowsMachines"][0]["label"], "Launch on AdomLapper")
self.assertEqual(p["message"], machines.PICKER_TEXT)
self.assertEqual(p["localOs"], "linux")
def test_a_clicked_machine_is_used(self):
self.assertEqual(machines.choose(None, self.rows, "m5-ubuntu", "arav-rog"), ("arav-rog", "picked"))
# a remembered machine that is gone or no longer Windows is not used
self.assertEqual(machines.choose(None, self.rows, "m5-ubuntu", "gone-pc")[0], None)
self.assertEqual(machines.choose(None, self.rows, "m5-ubuntu", "old-pc")[0], None)
def test_a_windows_pc_drives_itself_without_a_pick(self):
self.assertEqual(machines.choose(None, self.rows, "adomlapper", None), ("AdomLapper", "this_computer"))
def test_never_the_first_machine_listed(self):
# an unknown local computer (a cloud container) gets the picker, not AdomLapper
self.assertEqual(machines.choose(None, self.rows, None, None), (None, "no_machine_picked"))
def test_an_explicit_name_is_honoured_when_listed(self):
self.assertEqual(machines.choose("adomlapper", self.rows, "m5-ubuntu", None), ("AdomLapper", "named"))
self.assertEqual(machines.choose("nope", self.rows, "m5-ubuntu", None), (None, "not_listed"))
def test_no_windows_machine_says_how_to_add_one(self):
rows = machines.rows_from_targets({"targets": [{"name": "m5-ubuntu", "os": "Linux", "reachable": True}]})
p = machines.picker_payload(rows, "m5-ubuntu")
self.assertTrue(p["noWindowsMachine"])
self.assertEqual(p["message"], machines.NO_WINDOWS_TEXT)
self.assertEqual(p["windowsMachines"], [])
def test_the_test_switch_makes_a_windows_pc_behave_like_linux(self):
os.environ["ADOM_ALTIUM_DASHBOARD_LOCAL_OS"] = "linux"
try:
self.assertEqual(machines.choose(None, self.rows, "AdomLapper", None), (None, "no_machine_picked"))
finally:
os.environ.pop("ADOM_ALTIUM_DASHBOARD_LOCAL_OS", None)
if __name__ == "__main__":
unittest.main()