import sys import tempfile from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) import unittest import deckit.display as display class Resolution(unittest.TestCase): def test_reads_adb(self): self.assertEqual( display.tablet_resolution({"display": {}}, adb=lambda: "Physical size: 1920x1200"), "1920x1200") def test_config_override(self): self.assertEqual( display.tablet_resolution({"display": {"resolution": "2560x1600"}}, adb=lambda: "1920x1200"), "2560x1600") class Swaybg(unittest.TestCase): def test_finds_the_image_for_an_output(self): root = Path(tempfile.mkdtemp()) d = root / "123" d.mkdir() (d / "cmdline").write_bytes(b"/usr/bin/swaybg\0-o\0DP-1\0-i\0/a.png\0-m\0fill\0") self.assertEqual(display._swaybg_for("DP-1", root), (123, "/a.png", "fill")) self.assertIsNone(display._swaybg_for("TAB", root)) if __name__ == "__main__": unittest.main()