aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 16:39:50 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 16:39:50 +0100
commit6b03740a8c9fb98b788549412f0ebf3cbae1d2de (patch)
tree85f9532f1efdc63ecebb9c42a3e7a3c0b764e5d3 /tests
parent4bc6d69fc0fbfc3de5fb84874985a26deb79fdb5 (diff)
downloaddeck-it-6b03740a8c9fb98b788549412f0ebf3cbae1d2de.tar.gz
deck-it-6b03740a8c9fb98b788549412f0ebf3cbae1d2de.zip
feat(tablet): clock fonts and sizes from keystone's Fonts page
The dim cover's time and date fonts move out of [tablet] clock_font and clock_font_date into keystone's fonts.json: "family" deckit-clock and deckit-date, each served at /fonts/<key>, and the "override" sizes deckit:clock and deckit:date (else deck.css's 8rem and 1.6rem). The date can now have a font of its own. theme.css carries the rules, so a save on the Fonts page reaches an open tablet page within 5s, with no restart and no flags in the tablet state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_server.py10
-rw-r--r--tests/test_theme.py16
2 files changed, 21 insertions, 5 deletions
diff --git a/tests/test_server.py b/tests/test_server.py
index 8f82e9f..4d734b4 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -143,14 +143,14 @@ class Server(unittest.TestCase):
from pathlib import Path
f = Path(tempfile.mkdtemp()) / "Graffiti.ttf"
f.write_bytes(b"\x00\x01\x00\x00clock")
- with mock.patch.dict(srv.CFG, {"tablet": {"clock_font": "a Graffiti"}}):
+ with mock.patch.object(srv.theme, "families", return_value={"deckit-date": "a Graffiti"}):
with mock.patch.object(srv, "_run", return_value=f"a Graffiti\n{f}"):
- self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0:2], (200, b"\x00\x01\x00\x00clock"))
+ self.assertEqual(self.req("GET", "/fonts/deckit-date?f=a%20Graffiti", HOST)[0:2],
+ (200, b"\x00\x01\x00\x00clock"))
+ self.assertEqual(self.req("GET", "/fonts/deckit-clock", HOST)[0], 404) # unset
# fc-match's fallback for a font that is not installed
with mock.patch.object(srv, "_run", return_value="DejaVu Sans\n/usr/share/fonts/DejaVuSans.ttf"):
- self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0], 404)
- with mock.patch.dict(srv.CFG, {"tablet": {}}):
- self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0], 404)
+ self.assertEqual(self.req("GET", "/fonts/deckit-date", HOST)[0], 404)
def test_assets_and_api(self):
self.assertEqual(self.req("GET", "/", HOST)[0], 200)
diff --git a/tests/test_theme.py b/tests/test_theme.py
index f14b0f1..1c79370 100644
--- a/tests/test_theme.py
+++ b/tests/test_theme.py
@@ -61,6 +61,22 @@ class Theme(unittest.TestCase):
for bad in ('{"base": 99}', '{"base": "16"}', "not json", "[]"):
self.assertIsNone(theme.parse_font_size(bad))
+ def test_clock_fonts_from_fonts_json(self):
+ fams = theme.parse_families('{"base": 16, "family": {"deckit-date": " a Tag ", "deckit-clock": "", "qt": "x"}}')
+ self.assertEqual(fams, {"deckit-date": "a Tag"})
+ for bad in ("", "nope", '{"family": "x"}', "[]"):
+ self.assertEqual(theme.parse_families(bad), {})
+ out = theme.css({}, None, fams=fams)
+ self.assertIn('src: url("/fonts/deckit-date?f=a%20Tag")', out)
+ self.assertIn("#dimmer .dim-date", out)
+ self.assertNotIn("dim-time", out)
+
+ def test_clock_sizes_from_fonts_json(self):
+ sizes = theme.parse_clock_sizes('{"override": {"deckit:clock": 180.4, "deckit:date": 2, "deckit": 18}}')
+ self.assertEqual(sizes, {".dim-time": 180}) # 2px is out of range
+ self.assertEqual(theme.parse_clock_sizes("nope"), {})
+ self.assertIn("#dimmer .dim-time { font-size: 180px; }", theme.css({}, None, clock_sizes=sizes))
+
def test_css_exposes_font_size(self):
self.assertIn("--udt-font-size: 17px", theme.css({}, None, font_size=17))
self.assertIn(f"--udt-font-size: {theme.FONT_SIZE}px", theme.css({}, None))