Mercurial > p > roundup > code
diff test/test_config.py @ 6584:770503bd211e
Validate SecretOption and support validate method
Needed to validate SecretOption and verify that file is readable
and valid.
validator() now calls the validate method for each Option subclass.
To add post config load validation, just define a method
validate(self, options) for the Option subclass.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 06 Jan 2022 21:22:26 -0500 |
| parents | b1f1539c6a31 |
| children | 0d99ae7c8de6 |
line wrap: on
line diff
--- a/test/test_config.py Wed Jan 05 15:19:33 2022 -0500 +++ b/test/test_config.py Thu Jan 06 21:22:26 2022 -0500 @@ -441,6 +441,7 @@ # look for 'not defined' self.assertEqual("not defined", cm.exception.args[1]) + def testUnsetMailPassword_with_unset_username(self): """ Set [mail] username but don't set the [mail] password. Should get an OptionValueError. @@ -461,10 +462,8 @@ config = configuration.CoreConfig() - config.load(self.dirname) - with self.assertRaises(configuration.OptionValueError) as cm: - self.assertEqual(config['WEB_SECRET_KEY'],"") + config.load(self.dirname) print(cm.exception) self.assertEqual(cm.exception.args[0].setting, "secret_key") @@ -514,10 +513,8 @@ config = configuration.CoreConfig() - config.load(self.dirname) - with self.assertRaises(configuration.OptionValueError) as cm: - config['WEB_SECRET_KEY'] + config.load(self.dirname) print(cm.exception.args) self.assertEqual(cm.exception.args[2],"Value must not be empty.")
