~canonical-platform-qa/uci-config/fix1415642-empty_option

« back to all changes in this revision

Viewing changes to uciconfig/tests/test_options.py

  • Committer: Vincent Ladeuil
  • Date: 2014-02-15 16:49:46 UTC
  • Revision ID: vila+ci@canonical.com-20140215164946-ucjn2xiw6k0wcw8k
Support a specific MANDATORY default value for options that must be set.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        opt = options.Option('foo', 'foo help.', default=bar)
44
44
        self.assertEqual('bar', opt.get_default())
45
45
 
 
46
    def test_mandatory_option(self):
 
47
        opt = options.Option('foo', 'Foo help.', default=options.MANDATORY)
 
48
        with self.assertRaises(errors.OptionMandatoryValueError) as cm:
 
49
            opt.get_default()
 
50
        self.assertEqual('foo must be set.', unicode(cm.exception))
 
51
 
46
52
    def test_default_value_from_env(self):
47
53
        opt = options.Option('foo', 'foo help.', default='bar',
48
54
                             default_from_env=['FOO'])