Add config validator test
authorJack Miller <jack@codezen.org>
Sun, 23 Nov 2014 02:49:43 +0000 (20:49 -0600)
committerJack Miller <jack@codezen.org>
Sun, 23 Nov 2014 07:35:40 +0000 (01:35 -0600)
Not sure if this is totally anemic and should test every specific
validator or be left as is, just ensuring that when a validator fails
its value is properly rejected.

Definite room for expansion.

tests/test-config-validators.py [new file with mode: 0755]

diff --git a/tests/test-config-validators.py b/tests/test-config-validators.py
new file mode 100755 (executable)
index 0000000..772edb5
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from base import *
+
+from canto_curses.main import CANTO_PROTOCOL_COMPATIBLE
+from canto_curses.config import config
+
+import time
+
+class TestConfigValidators(Test):
+    def check(self):
+        script = {
+            'VERSION' : { '*' : ('VERSION', CANTO_PROTOCOL_COMPATIBLE) },
+            'CONFIGS' : { '*' : ('CONFIGS', { "CantoCurses" : config.template_config }) },
+                
+        }
+
+        backend = TestBackend("config", script)
+
+        config.init(backend, CANTO_PROTOCOL_COMPATIBLE)
+
+        # We only want to test failure. Success will be tested by the config hook test.
+
+        really_bad_config = eval(repr(config.template_config))
+        really_bad_config["browser"]["text"] = "badoption"
+
+        backend.inject("CONFIGS", { "CantoCurses" : really_bad_config })
+        
+        return config.config == config.template_config
+
+TestConfigValidators("config validators")