def test_config_get(self): """Test the most important function of the config module: config_get""" # generate and set data configuration = [] for key, value in self.testconfig.iteritems(): configuration += ["--" + key] if value: configuration += [str(value)] config.set_data(configuration) # check we can read back the data we set config.config_get(('server', 'port')) self.assertEqual(config.config_get(('server', 'port')), 6000, "can't find argument values set by set_data") self.assertEqual( config.config_get("nonexisting", None), None, "config_get doesn't return None on a nonexisting param")
def test_config_get(self): """Test the most important function of the config module: config_get""" # generate and set data configuration = [] for key, value in self.testconfig.iteritems(): configuration += ["--" + key] if value: configuration += [str(value)] config.set_data(configuration) # check we can read back the data we set config.config_get(('server', 'port')) self.assertEqual(config.config_get(('server', 'port')), 6000, "can't find argument values set by set_data") self.assertEqual(config.config_get("nonexisting", None), None, "config_get doesn't return None on a nonexisting param")
def test_set_data_and_set_conf(self): """Test the set_data and set_conf functions""" # generate and set data configuration = [] for key, value in self.testconfig.iteritems(): configuration += ["--" + key] if value: configuration += [str(value)] config.set_data(configuration) # check we can read back the data we set self.assertEqual(config.config_get(("server", "port")), 6000, "can't find argument values set by set_data") self.assertEqual(config.config_get(("logging", "verbose")), True, "can't find argument values set by set_data") # check that the system exits when we give unrecognized arguments config.set_data("--some values --that --dont --exist".split()) self.assertRaises(SystemExit, config._set_conf)
def test_set_data_and_set_conf(self): """Test the set_data and set_conf functions""" # generate and set data configuration = [] for key, value in self.testconfig.iteritems(): configuration += ["--" + key] if value: configuration += [str(value)] config.set_data(configuration) # check we can read back the data we set self.assertEqual(config.config_get(("server","port")), 6000, "can't find argument values set by set_data") self.assertEqual(config.config_get(("logging", "verbose")), True, "can't find argument values set by set_data") # check that the system exits when we give unrecognized arguments config.set_data("--some values --that --dont --exist".split()) self.assertRaises(SystemExit, config._set_conf)
def set_data(id_, data): config.set_data(os.path.join(id_, config.OPTIONS_FILE), data)