# deck-it - tests for config # Copyright (C) 2026 Danilo M. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # tests/test_config.py import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT)) import tomllib import unittest import deckit.config as config class Config(unittest.TestCase): def test_default_config_is_valid(self): with open(ROOT / "config.toml", "rb") as f: self.assertIsNone(config.config_error(tomllib.load(f))) def test_rejects_bad_values(self): bad = [{"display": {"name": "TAB;rm"}}, {"display": {"refresh": 0}}, {"ports": {"command_center": 80}}, {"ports": {"command_center": 5900, "display": 5900}}] for cfg in bad: self.assertIsNotNone(config.config_error(cfg), cfg) def test_user_config_path_honours_xdg(self): self.assertEqual(config.user_config_path().name, "config.toml") self.assertEqual(config.user_config_path().parent.name, "deck-it") if __name__ == "__main__": unittest.main()