ProPresenter guard at every location: install.sh starts it where ProPresenter is, it finds ProPresenter's port, leaves a song already up alone; restart off by default
WS and SC updated to the current build (code only, their settings kept). NA's Resi cues polling slowed to 10 s / 20 s (Companion setting). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,18 +37,24 @@ class FakeProP:
|
||||
class TestGuard(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.fake, self.clock = FakeProP(), [1000.0]
|
||||
self.orig = pg.api
|
||||
self.orig, self.cfg = pg.api, dict(pg.CFG)
|
||||
pg.api = self.fake
|
||||
pg.CFG["resume"] = True # off by default; these tests turn it on
|
||||
self.g = pg.Guard(now=lambda: self.clock[0])
|
||||
|
||||
def tearDown(self):
|
||||
pg.api = self.orig
|
||||
pg.CFG.clear()
|
||||
pg.CFG.update(self.cfg)
|
||||
|
||||
def at(self, t):
|
||||
self.clock[0] = 1000.0 + t
|
||||
self.g.tick()
|
||||
|
||||
def test_stage_put_on_worship_when_the_macro_missed(self):
|
||||
song, self.fake.song = self.fake.song, None # the guard watching before the song starts
|
||||
self.at(-1)
|
||||
self.fake.song = song
|
||||
self.at(0)
|
||||
self.assertEqual(self.fake.layout, "MC") # judged only after a few seconds
|
||||
self.at(3)
|
||||
@@ -124,3 +130,79 @@ class TestTimecode(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class TestEveryLocation(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.orig, self.cfg = pg.api, dict(pg.CFG)
|
||||
|
||||
def tearDown(self):
|
||||
pg.api = self.orig
|
||||
pg.CFG.clear()
|
||||
pg.CFG.update(self.cfg)
|
||||
|
||||
def test_restart_is_off_unless_a_location_turns_it_on(self):
|
||||
self.assertFalse(self.cfg["resume"])
|
||||
|
||||
def test_the_api_port_is_found_when_the_set_one_does_not_answer(self):
|
||||
import http.server
|
||||
import json
|
||||
import threading
|
||||
|
||||
class H(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps({"api_version": "v1"}).encode())
|
||||
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
srv = http.server.HTTPServer(("127.0.0.1", 0), H)
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
try:
|
||||
pg.CFG["api"] = "http://127.0.0.1:1"
|
||||
port = srv.server_address[1]
|
||||
self.assertEqual(pg.find_api(ports=lambda: [1, port]), "http://127.0.0.1:%d" % port)
|
||||
self.assertEqual(pg.CFG["api"], "http://127.0.0.1:%d" % port)
|
||||
pg.CFG["api"] = "http://127.0.0.1:1"
|
||||
self.assertIsNone(pg.find_api(ports=lambda: []))
|
||||
finally:
|
||||
srv.shutdown()
|
||||
|
||||
def test_without_a_screen_called_stage_display_the_first_stage_screen_is_used(self):
|
||||
pg.api = lambda path, timeout=2.0: [{"screen": {"uuid": "B", "name": "Band", "index": 1}, "layout": {"name": "X"}},
|
||||
{"screen": {"uuid": "A", "name": "Front", "index": 0}, "layout": {"name": "Y"}}]
|
||||
screen, layout = pg.Guard().stage()
|
||||
self.assertEqual((screen["uuid"], layout["name"]), ("A", "Y"))
|
||||
|
||||
|
||||
class TestStart(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.fake, self.clock, self.orig = FakeProP(), [1000.0], pg.api
|
||||
pg.api = self.fake
|
||||
self.g = pg.Guard(now=lambda: self.clock[0])
|
||||
|
||||
def tearDown(self):
|
||||
pg.api = self.orig
|
||||
|
||||
def at(self, t):
|
||||
self.clock[0] = 1000.0 + t
|
||||
self.g.tick()
|
||||
|
||||
def test_a_song_already_up_when_the_guard_starts_is_left_alone(self):
|
||||
self.fake.calls.clear()
|
||||
self.at(0) # the guard (re)starts mid-song, stage on Message
|
||||
self.at(3)
|
||||
self.assertEqual(self.fake.layout, "MC")
|
||||
self.fake.song = "Goodness" # the next song is judged as usual
|
||||
self.at(10)
|
||||
self.at(13)
|
||||
self.assertEqual(self.fake.layout, "Worship")
|
||||
|
||||
def test_prop_not_answering_at_the_start_does_not_count_as_seen(self):
|
||||
pg.api = lambda path, timeout=2.0: None
|
||||
self.at(0)
|
||||
pg.api = self.fake
|
||||
self.at(1) # first answer: this song was already up
|
||||
self.at(4)
|
||||
self.assertEqual(self.fake.layout, "MC")
|
||||
|
||||
Reference in New Issue
Block a user