aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 14:06:41 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 14:06:41 +0100
commit863f7453f9e136cadc93db9f3f0b8f257f798ce8 (patch)
treea24c2453dd0d9b8e7317378ee8da56e205a0f3bb /tests
parentfe55526cbc6015c4268ee155f21bcb11de5609b5 (diff)
downloaddeck-it-863f7453f9e136cadc93db9f3f0b8f257f798ce8.tar.gz
deck-it-863f7453f9e136cadc93db9f3f0b8f257f798ce8.zip
feat(tablet): a font of the PC's for the dim cover's clock
[tablet] clock_font names a font family installed on the PC; the server finds its file with fc-match and serves it at /fonts/clock, and the cover's clock uses it, the date too while clock_font_date is on (default). fc-match falls back to any font, so the route answers only when the returned family is the one named; otherwise the page font stays. The font file never enters the repo, so a personal-use font can be used on one's own tablet without redistributing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_server.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_server.py b/tests/test_server.py
index 522b781..8f82e9f 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -137,6 +137,21 @@ class Server(unittest.TestCase):
self.assertEqual(self.req("GET", "/fonts/nerd.ttf", HOST)[0], 404)
srv._font.clear()
+ def test_clock_font(self):
+ from unittest import mock
+ import tempfile
+ 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, "_run", return_value=f"a Graffiti\n{f}"):
+ self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0:2], (200, b"\x00\x01\x00\x00clock"))
+ # 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)
+
def test_assets_and_api(self):
self.assertEqual(self.req("GET", "/", HOST)[0], 200)
self.assertEqual(self.req("GET", "/theme.css", HOST)[0], 200)