From 62553aba1fa1f011cfe4d4d49ada0d15ad13465f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 23 Aug 2013 09:29:42 +0200 Subject: [PATCH] test invalid owner in setowner --- test/test_option_owner.py | 10 ++++++++++ test/test_permissive.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/test_option_owner.py b/test/test_option_owner.py index 5ec59ea..12e10e7 100644 --- a/test/test_option_owner.py +++ b/test/test_option_owner.py @@ -1,4 +1,5 @@ import autopath +from py.test import raises from tiramisu.setting import owners from tiramisu.config import Config @@ -60,3 +61,12 @@ def test_owner_is_not_a_string(): assert isinstance(cfg.getowner('dummy'), owners.Owner) cfg.dummy = True assert cfg.getowner('dummy') == 'user' + + +def test_setowner_without_valid_owner(): + gcdummy = BoolOption('dummy', 'dummy', default=False) + descr = OptionDescription('tiramisu', '', [gcdummy]) + cfg = Config(descr) + assert cfg.dummy is False + assert cfg.getowner('dummy') == 'default' + raises(TypeError, "cfg.cfgimpl_get_settings().setowner('gen_config')") diff --git a/test/test_permissive.py b/test/test_permissive.py index cd9b434..7365531 100644 --- a/test/test_permissive.py +++ b/test/test_permissive.py @@ -1,5 +1,7 @@ # coding: utf-8 import autopath +from py.test import raises + from tiramisu.option import IntOption, OptionDescription from tiramisu.config import Config from tiramisu.error import PropertiesOptionError @@ -81,3 +83,11 @@ def test_permissive_frozen(): except PropertiesOptionError, err: props = err.proptype assert props == ['frozen', 'disabled'] + + +def test_invalid_permissive(): + descr = make_description() + config = Config(descr) + setting = config.cfgimpl_get_settings() + config.read_write() + raises(TypeError, "setting.setpermissive(['frozen', 'disabled',])")