def test_override_with_args_level(self): """Test adding config options from dictionary at higher level """ conf.load(self.filename) conf["section_1.section_12.a"] = "15" self.assertEqual(conf["section_1.section_12.a"], "15") conf.override_with_args([("section_1.section_12.a", "13")]) self.assertEqual(conf["section_1.section_12.a"], "13")
def test_override_with_args_level(self): """Test adding config options from dictionary at higher level """ conf.load(self.filename) conf['section_1.section_12.a'] = '15' self.assertEqual(conf['section_1.section_12.a'], '15') conf.override_with_args([('section_1.section_12.a', '13')]) self.assertEqual(conf['section_1.section_12.a'], '13')
def test_override_with_args(self): """Test adding config options from dictionary """ conf.load(self.filename) self.assertTrue("section_1.a" in conf) self.assertEqual(conf["section_1.a"], "12") conf.override_with_args([("section_1.a", "13")]) self.assertEqual(conf["section_1.a"], "13")
def test_override_with_args(self): """Test adding config options from dictionary """ conf.load(self.filename) self.assertTrue('section_1.a' in conf) self.assertEqual(conf['section_1.a'], '12') conf.override_with_args([('section_1.a', '13')]) self.assertEqual(conf['section_1.a'], '13')
def test_override_with_args_spec(self): """Test adding config options with a spec """ spec = "[section_1]\n" "a = integer(min=0, default=5, max=13)" conf.load(self.filename, spec=([option.encode() for option in spec.split("\n")])) conf.override_with_args([("section_1.a", "13")]) self.assertEqual(conf["section_1.a"], "13") conf.validate_config(conf.base) self.assertEqual(conf["section_1.a"], 13)
def test_override_with_args_spec(self): """Test adding config options with a spec """ spec = ("[section_1]\n" "a = integer(min=0, default=5, max=13)") conf.load(self.filename, spec=([option.encode() for option in spec.split('\n')])) conf.override_with_args([('section_1.a', '13')]) self.assertEqual(conf['section_1.a'], '13') conf.validate_config(conf.base) self.assertEqual(conf['section_1.a'], 13)
def test_override_with_args_wrong(self): """Test adding config options with a wrong spec """ spec = "[section_1]\n" "a = integer(min=0, default=5, max=12)" expected_error = ( r"Configuration does not adhere to the specification: " r"\[\(\['section_1'\], 'a', " r"VdtValueTooBigError\('the value \"13\" is too big.',\)\)\]" ) conf.load(self.filename, spec=([option.encode() for option in spec.split("\n")])) conf.override_with_args([("section_1.a", "13")]) self.assertRaisesRegexp(ValueError, expected_error, conf.validate_config, conf.base)
def test_override_with_args_wrong(self): """Test adding config options with a wrong spec """ spec = ("[section_1]\n" "a = integer(min=0, default=5, max=12)") expected_error = ( r"Configuration does not adhere to the specification: " r"\[\(\['section_1'\], 'a', " r"VdtValueTooBigError\('the value \"13\" is too big.',\)\)\]") conf.load(self.filename, spec=([option.encode() for option in spec.split('\n')])) conf.override_with_args([('section_1.a', '13')]) self.assertRaisesRegexp(ValueError, expected_error, conf.validate_config, conf.base)