okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-027-gh-app: GitHub app and Terminal items for 0.2.73cabb9e3f

main
1.2 KiB32 linesraw
1"""serve/test_web_badges.py - the Recent requests table has a badge for every way a request can end (#3991).
2
3A request that waits past the queue limit ends with finish "timeout"; the Status cell showed the raw word. Reads the page source.
4"""
5from __future__ import annotations
6
7import re
8import unittest
9from pathlib import Path
10
11APP = Path(__file__).resolve().parent / "web" / "app.js"
12SERVER = Path(__file__).resolve().parent / "server.py"
13
14
15class FinishBadges(unittest.TestCase):
16    def test_a_timed_out_request_has_a_badge(self):
17        src = APP.read_text(encoding="utf-8")
18        table = src[src.index("const badge = {stop:"):]
19        table = table[:table.index("};")]
20        self.assertRegex(table, r'timeout: \["st-badge--queued", "Timeout"\]')
21
22    def test_every_finish_the_server_stores_has_a_badge(self):
23        src = APP.read_text(encoding="utf-8")
24        table = src[src.index("const badge = {stop:"):]
25        table = table[:table.index("};")]
26        for finish in ("stop", "length", "cancel", "disconnect", "error", "timeout"):
27            self.assertRegex(table, rf"\b{finish}:", finish)
28        self.assertIn('"timeout"', SERVER.read_text(encoding="utf-8"))
29
30
31if __name__ == "__main__":
32    unittest.main()