def test_true_false_good(self):
     bindings = YamlBindings()
     bindings.import_dict(
         {'t': True, 'f':False, 'indirect':'${t}', 'default': '${x:true}'})
     validator = ValidateConfig(
           configurator=Configurator(bindings=bindings))
     self.assertTrue(validator.verify_true_false('t'))
     self.assertTrue(validator.verify_true_false('f'))
     self.assertTrue(validator.verify_true_false('indirect'))
     self.assertTrue(validator.verify_true_false('default'))
 def test_true_false_good(self):
     bindings = YamlBindings()
     bindings.import_dict(
         {'t': True, 'f':False, 'indirect':'${t}', 'default': '${x:true}'})
     validator = ValidateConfig(
           configurator=Configurator(bindings=bindings))
     self.assertTrue(validator.verify_true_false('t'))
     self.assertTrue(validator.verify_true_false('f'))
     self.assertTrue(validator.verify_true_false('indirect'))
     self.assertTrue(validator.verify_true_false('default'))
 def test_true_false_not_resolved(self):
     bindings = YamlBindings()
     bindings.import_dict({'indirect': '${t}'})
     validator = ValidateConfig(
           configurator=Configurator(bindings=bindings))
     self.assertFalse(validator.verify_true_false('indirect'))
     self.assertEqual('Missing "indirect".', validator.errors[0])
Esempio n. 4
0
 def test_true_false_not_resolved(self):
     bindings = YamlBindings()
     bindings.import_dict({'indirect': '${t}'})
     validator = ValidateConfig(configurator=Configurator(
         bindings=bindings))
     self.assertFalse(validator.verify_true_false('indirect'))
     self.assertEqual('Missing "indirect".', validator.errors[0])
 def test_true_false_bad(self):
     bindings = YamlBindings()
     bindings.import_dict(
         {'t': 'true', 'f':'false', 'indirect':'${t}', 'default': '${x:0}'})
     validator = ValidateConfig(
           configurator=Configurator(bindings=bindings))
     self.assertFalse(validator.verify_true_false('t'))
     self.assertFalse(validator.verify_true_false('f'))
     self.assertFalse(validator.verify_true_false('indirect'))
     self.assertFalse(validator.verify_true_false('default'))
     self.assertEqual(4, len(validator.errors))
     self.assertEqual(0, len(validator.warnings))
     self.assertEqual(
         ["t='true' is not valid. Must be boolean true or false.",
          "f='false' is not valid. Must be boolean true or false.",
          "indirect='true' is not valid. Must be boolean true or false.",
          "default=0 is not valid. Must be boolean true or false."],
         validator.errors)
 def test_true_false_bad(self):
     bindings = YamlBindings()
     bindings.import_dict(
         {'t': 'true', 'f':'false', 'indirect':'${t}', 'default': '${x:0}'})
     validator = ValidateConfig(
           configurator=Configurator(bindings=bindings))
     self.assertFalse(validator.verify_true_false('t'))
     self.assertFalse(validator.verify_true_false('f'))
     self.assertFalse(validator.verify_true_false('indirect'))
     self.assertFalse(validator.verify_true_false('default'))
     self.assertEqual(4, len(validator.errors))
     self.assertEqual(0, len(validator.warnings))
     self.assertEqual(
         ["t='true' is not valid. Must be boolean true or false.",
          "f='false' is not valid. Must be boolean true or false.",
          "indirect='true' is not valid. Must be boolean true or false.",
          "default=0 is not valid. Must be boolean true or false."],
         validator.errors)