add more tests
[tiramisu.git] / test / test_config.py
index 6a4f6b4..5cdbe7d 100644 (file)
@@ -152,8 +152,10 @@ def test_config_impl_get_path_by_opt():
     config = Config(descr)
     dummy = config.unwrap_from_path('gc.dummy')
     boo = config.unwrap_from_path('bool')
+    unknown = IntOption('test', '')
     assert config.cfgimpl_get_description().impl_get_path_by_opt(boo) == 'bool'
     assert config.cfgimpl_get_description().impl_get_path_by_opt(dummy) == 'gc.dummy'
+    raises(AttributeError, "config.cfgimpl_get_description().impl_get_path_by_opt(unknown)")
 
 
 def test_config_impl_get_opt_by_path():
@@ -163,6 +165,7 @@ def test_config_impl_get_opt_by_path():
     boo = config.unwrap_from_path('bool')
     assert config.cfgimpl_get_description().impl_get_opt_by_path('bool') == boo
     assert config.cfgimpl_get_description().impl_get_opt_by_path('gc.dummy') == dummy
+    raises(AttributeError, "config.cfgimpl_get_description().impl_get_opt_by_path('gc.unknown')")
 
 
 def test_information_display():
@@ -254,3 +257,20 @@ def test_config_multi():
     assert config.test3 == [2]
     config.test3.append()
     assert config.test3 == [2, 1]
+
+
+def test_no_validation():
+    i1 = IntOption('test1', '')
+    od = OptionDescription('test', '', [i1])
+    c = Config(od)
+    setting = c.cfgimpl_get_settings()
+    c.test1 = 1
+    raises(ValueError, 'c.test1 = "yes"')
+    assert c.test1 == 1
+    setting.remove('validator')
+    c.test1 = "yes"
+    assert c.test1 == "yes"
+    setting.append('validator')
+    raises(ValueError, 'c.test1')
+    del(c.test1)
+    assert c.test1 == None