1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00
supysonic/tests/base/test_config.py

46 lines
1.4 KiB
Python
Raw Normal View History

2018-03-04 20:49:56 +00:00
#!/usr/bin/env python
# coding: utf-8
2017-12-10 17:22:03 +00:00
#
# This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
#
# Copyright (C) 2017-2018 Alban 'spl0k' Féron
2017-12-10 17:22:03 +00:00
#
# Distributed under terms of the GNU AGPLv3 license.
import unittest
from supysonic.config import IniConfig
2018-01-08 22:13:50 +00:00
from supysonic.py23 import strtype
2017-12-10 17:22:03 +00:00
2019-06-29 15:25:44 +00:00
2017-12-10 17:22:03 +00:00
class ConfigTestCase(unittest.TestCase):
def test_sections(self):
2019-06-29 15:25:44 +00:00
conf = IniConfig("tests/assets/sample.ini")
for attr in ("TYPES", "BOOLEANS"):
2017-12-10 17:22:03 +00:00
self.assertTrue(hasattr(conf, attr))
self.assertIsInstance(getattr(conf, attr), dict)
def test_types(self):
2019-06-29 15:25:44 +00:00
conf = IniConfig("tests/assets/sample.ini")
2017-12-10 17:22:03 +00:00
2019-06-29 15:25:44 +00:00
self.assertIsInstance(conf.TYPES["float"], float)
self.assertIsInstance(conf.TYPES["int"], int)
self.assertIsInstance(conf.TYPES["string"], strtype)
2017-12-10 17:22:03 +00:00
2019-06-29 15:25:44 +00:00
for t in ("bool", "switch", "yn"):
self.assertIsInstance(conf.BOOLEANS[t + "_false"], bool)
self.assertIsInstance(conf.BOOLEANS[t + "_true"], bool)
self.assertFalse(conf.BOOLEANS[t + "_false"])
self.assertTrue(conf.BOOLEANS[t + "_true"])
2017-12-10 17:22:03 +00:00
def test_no_interpolation(self):
2019-06-29 15:25:44 +00:00
conf = IniConfig("tests/assets/sample.ini")
2019-06-29 15:25:44 +00:00
self.assertEqual(conf.ISSUE84["variable"], "value")
self.assertEqual(conf.ISSUE84["key"], "some value with a %variable")
2017-12-10 17:22:03 +00:00
2019-06-29 15:25:44 +00:00
if __name__ == "__main__":
unittest.main()