def test_load_custom_config_file(self): # create custom config file, modify service name filepath = "/tmp/{}".format(int(time.time())) with open(filepath, "w") as file: file.write("[SERVICE]\nname = flask\n") config = Configuration(filepath=filepath) self.assertEqual(config.get("SERVICE", "name"), "flask")
def test_sections(self): config = Configuration() self.assertSetEqual( set(config.sections()), {"SERVICE", "FRONTEND", "SERVICE:FLASK"})
def test_nonexisting_config_filepath(self): filepath = "/tmp/{}".format(time.time()) with self.assertRaises(InvalidConfigError) as cm: Configuration(filepath=filepath) self.assertTrue( cm.exception.args[0].endswith("Config filepath does not exist!"))
def test_get_option(self): config = Configuration() self.assertEqual(config.get_option("SERVICE", "name"), "none") self.assertDictEqual(config.get_option("SERVICE"), {"name": "none"})