Steps 4-6: the jobs, the set-up tab with generated scripts, Install the staged folder, site bundles and the campus template
- Overview jobs: Change the playlist, Add or remove a HyperDeck, Add a MIDI link, Add a computer, Make a PC program startable; 'Add a key for it' on unwatched Companion connections. - Computers > Setup: steps with a [how] each and the set-up scripts generated per computer by settings/scripts.py from the templates in remote-access/ (no site-shaped value left in them); Remove this computer drops the fixes and checks that used it. - Site setup > Site: the running and staged code, Install the staged folder (a one-shot launchd job running install.sh --keep-config, refused while live), Export site bundle (zip), New campus from a bundle (this campus's site block stays; every copied computer is flagged until touched). - sites/: na -> the repo config, _template = the empty campus; install.sh --site <id>. - Review reads appended checks as 'added'; tests for all of it. - Deployed page-only to NA Ingest. (config.json, status_panel.py and readiness.py are left to the READY-page work in progress in the same tree.) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
"""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(len(scripts.setup_for(CFG, "ingest")["scripts"]), 1)
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user