diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_config.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..ff56325 --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,33 @@ +# 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() |
