Merge branch 'ui-3-home' into ui-4-store

This commit is contained in:
saphid committed 2026-10-01 23:08:06 +10:00
commit cc9af9eba4
3 files changed
+39 -20

No files matched your search

+28 -14
View File
@@ -459,27 +459,41 @@ class Connecting(unittest.TestCase):
def test_a_test_started_earlier_cant_overwrite_a_newer_one(self):
d = self.device("nothing.invalid")
release, calls = threading.Event(), []
entered = {1: threading.Event(), 2: threading.Event()}
release = {1: threading.Event(), 2: threading.Event()}
calls = []
def probe(host, port, update=None):
calls.append(host)
if len(calls) == 1:
release.wait(10) # the first test is still probing when the second finishes
return {"state": "refused", "detail": "first test", "ip": None, "rtt_ms": None}
return {"state": "refused", "detail": "second test", "ip": None, "rtt_ms": None}
n = len(calls)
entered[n].set()
release[n].wait(10)
return {"state": "refused", "detail": f"test {n}", "ip": None, "rtt_ms": None}
tests = [threading.Thread(target=self.link.test, args=(d["id"],), daemon=True) for _ in range(2)]
with mock.patch.object(fl, "probe", probe):
first = threading.Thread(target=self.link.test, args=(d["id"],))
first.start()
while not calls:
time.sleep(0.01)
self.link.test(d["id"])
self.assertEqual(self.link.snapshot()["tests"][d["id"]]["rows"][0]["detail"], "second test")
release.set()
first.join(10)
try:
tests[0].start()
self.assertTrue(entered[1].wait(5), "the first test never probed")
tests[1].start()
self.assertTrue(entered[2].wait(5), "the second test never probed")
# The first finishes while the second is still probing: it mustn't show its
# rows or mark the second done.
release[1].set()
tests[0].join(10)
self.assertFalse(tests[0].is_alive())
running = self.link.snapshot()["tests"][d["id"]]
self.assertFalse(running["done"])
self.assertEqual(running["rows"][0]["detail"], "Waiting")
release[2].set()
tests[1].join(10)
self.assertFalse(tests[1].is_alive())
finally:
for e in release.values():
e.set()
result = self.link.snapshot()["tests"][d["id"]]
self.assertTrue(result["done"])
self.assertEqual(result["rows"][0]["detail"], "second test")
self.assertEqual(result["rows"][0]["detail"], "test 2")
def test_switching_to_a_headset_that_never_answers_stops_using_the_last_one(self):
self.device("localhost")