Files
christianandClaude Fable 5.1 10e545d4e0 ATEM: read the saved-file folder through this Mac's own Remote Login when macOS keeps the page out of Google Drive
A launchd-run python3 gets 'Operation not permitted' on ~/Library/CloudStorage; sshd does not. The
page now lists and reads the folder over ssh to localhost with the panel's own key when the local
read is blocked (the Ingest Mac's Setup card gains that authorise step). Pick the newest verified
on NA Ingest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-14 15:18:39 -04:00

99 lines
5.0 KiB
Python

"""The generated set-up scripts and the campus template: every value comes from the record, the
templates hold no site-shaped value, and the empty campus validates and builds its pages."""
import json
import os
import sys
import unittest
from unittest import mock
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, ROOT)
import make_page # noqa: E402
import schema # noqa: E402
from settings import scripts # noqa: E402
CFG = json.load(open(os.path.join(ROOT, "config.json")))
KEY = ("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHM2BPUpVpbMxKumLayVSutUsFWUXEfJ/4vxIJ0thbgY status-panel@NA-Ingest", "status-panel@NA-Ingest")
class TestScripts(unittest.TestCase):
def test_templates_hold_no_site_values(self):
for name in os.listdir(scripts.TEMPLATES):
if name.endswith(".template"):
text = open(os.path.join(scripts.TEMPLATES, name)).read()
for bad in ("NA Ingest", "NA-Ingest", "10.1.1.1", "10.6.3.222", "Vista.exe", "obs64", "Lighting PC", "AAAAC3"):
self.assertNotIn(bad, text, (name, bad))
def test_windows_script_lists_every_task_and_service(self):
with mock.patch.object(scripts, "public_key", lambda cfg: KEY):
text = scripts.windows_setup(CFG, "lighting")
self.assertIn("$Key = '%s'" % KEY[0], text)
self.assertIn("$KeyMark = 'status-panel@NA-Ingest'", text)
self.assertIn("$IngestIPs = @('10.1.1.1', '10.6.3.222')", text)
for exe in ("Vista.exe", "Arena.exe", "rtpMIDI.exe"):
self.assertIn("(Find-Exe '%s')" % exe, text)
self.assertIn("foreach ($svc in @('rtpMIDIService'))", text)
self.assertNotIn("{{", text)
cfg = json.loads(json.dumps(CFG))
for r in cfg["hosts"]["livestream"]["runs"]:
if r.get("exe") == "obs64.exe":
r["args"] = "--disable-shutdown-check"
obs = scripts.windows_setup(cfg, "livestream")
self.assertIn("@{ Name = 'OBS'; Exe = (Find-Exe 'obs64.exe'); Args = '--disable-shutdown-check' }", obs)
bible = scripts.windows_setup(CFG, "bibletv")
self.assertIn("AtLogon = $true", bible)
self.assertIn("run ONCE on Bible TV PC", bible)
def test_windows_values_are_checked(self):
cfg = json.loads(json.dumps(CFG))
cfg["hosts"]["lighting"]["runs"].append({"kind": "task", "name": "Start Bad", "exe": "x & del.exe"})
with mock.patch.object(scripts, "public_key", lambda cfg: KEY):
with self.assertRaises(ValueError):
scripts.windows_setup(cfg, "lighting")
page = scripts.setup_for(cfg, "lighting") # the page gets a note, not a crash
self.assertIn("cannot generate", page["scripts"][0]["text"])
def test_mac_scripts(self):
with mock.patch.object(scripts, "public_key", lambda cfg: KEY):
auth = scripts.mac_authorize(CFG)
self.assertIn("grep -q 'status-panel@NA-Ingest'", auth)
self.assertIn("echo '%s'" % KEY[0], auth)
self.assertIn("It lets NA Ingest's", auth)
dvs = scripts.mac_dvs_helper(CFG)
self.assertIn("select NA Ingest, ProPresenter Mac, Tracks Mac, NA Translation ->", dvs)
self.assertIn("/usr/local/sbin/status-panel-dvs-start", dvs)
solo = scripts.solo_install(CFG, "studiob")
self.assertIn(CFG["hosts"]["studiob"]["ssh"], solo)
def test_setup_for_every_computer(self):
with mock.patch.object(scripts, "public_key", lambda cfg: KEY):
for alias in CFG["hosts"]:
s = scripts.setup_for(CFG, alias)
self.assertTrue(s["steps"], alias)
self.assertTrue(all(x["how"] for x in s["steps"]), alias)
self.assertEqual([x["name"] for x in scripts.setup_for(CFG, "studiob")["scripts"]][-1], "Pro Tools solo-mode helper")
self.assertEqual([x["name"][:9] for x in scripts.setup_for(CFG, "ingest")["scripts"]], ["Authorise", "DVS helpe"])
def test_no_key_yet_is_said_not_crashed(self):
with mock.patch.object(scripts, "public_key", lambda cfg: (None, None)):
self.assertIn("no login key yet", scripts.mac_authorize(CFG))
class TestSites(unittest.TestCase):
def test_template_validates_and_builds(self):
cfg = json.load(open(os.path.join(ROOT, "sites", "_template", "config.json")))
errors, _ = schema.validate(cfg)
self.assertEqual(errors, [])
make_page.build(cfg)
self.assertEqual(sorted(t["kind"] for t in cfg["tiles"]), ["master", "network", "service"])
self.assertEqual([a for a, h in cfg["hosts"].items() if h.get("self")], ["ingest"])
self.assertEqual(cfg["hosts"]["ingest"]["networks"], [])
self.assertNotIn("Attleboro", json.dumps(cfg))
def test_na_is_the_repo_config(self):
self.assertEqual(json.load(open(os.path.join(ROOT, "sites", "na", "config.json"))), CFG)
if __name__ == "__main__":
unittest.main()