import unittest from ITPlanning.config import IniConfig class ConfigTestCase(unittest.TestCase): def test_sections(self): conf = IniConfig("tests/assets/sample.ini") for attr in ("TYPES", "BOOLEANS"): self.assertTrue(hasattr(conf, attr)) self.assertIsInstance(getattr(conf, attr), dict) def test_types(self): conf = IniConfig("tests/assets/sample.ini") self.assertIsInstance(conf.TYPES["float"], float) self.assertIsInstance(conf.TYPES["int"], int) self.assertIsInstance(conf.TYPES["string"], str) 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"]) if __name__ == "__main__": unittest.main()