Permalink
Browse files

added test suite for Configurable Class

  • Loading branch information...
Felix Richter Felix Richter
Felix Richter authored and Felix Richter committed Feb 1, 2011
1 parent c808c10 commit dd46a5e0f2a67cf353565f27644ee98a2b4a8adf
Showing with 32 additions and 5 deletions.
  1. +0 −2 genericore/utils.py
  2. +25 −0 tests/config_test.py
  3. +4 −0 tests/configurable.json
  4. +3 −3 tests/genericore.tests
View
@@ -36,8 +36,6 @@ def load_conf_file(self,config_file):
with open(config_file) as f:
new_conf = json.load(f,encoding='ascii')
self.load_conf(new_conf)
- def load_conf_parser(self,parser):
- """ loads the configuration from a parser object """
class Configurator(Configurable):
def __init__(self,PROTO_VERSION=1,DESCRIPTION='description not set!',conf=None):
View
@@ -0,0 +1,25 @@
+from genericore import Configurable
+
+def test_loadConstructor():
+ class cl(Configurable): pass
+ conf = {'a' : 'b'}
+ a = cl(conf)
+ assert a.config['a'] == 'b'
+
+def test_load_conf():
+ a = Configurable({'a' : 'b'})
+ assert a.config['a'] == 'b'
+
+ a.load_conf({'a' : { 'x' : 'y'}})
+ assert a.config['a']['x'] == 'y'
+
+ a.load_conf({'b' : 'd'})
+ assert a.config['a']['x'] == 'y'
+ assert a.config['b'] == 'd'
+
+def test_load_conf_file():
+ a = Configurable({'a' : {'x' : 'y'}})
+ a.load_conf_file('configurable.json')
+ assert a.config['a']['x'] == 'z'
+ assert a.config['b'] == 'd'
+
View
@@ -0,0 +1,4 @@
+{
+ "a" : { "x" : "z"},
+ "b" : "d"
+}
View
@@ -1,13 +1,13 @@
Test Cases
==========
1. Configurable
-1.1. Load via Constructor
+(x) 1.1. Load via Constructor
- create new class and derive from Configurable
- Check if sample config is loaded correctly
-1.2 Load via load_conf
+(x) 1.2 Load via load_conf
- create new class, use load_conf
- check if sample config is loaded correctly
-1.3 Load via load_conf_file
+(x) 1.3 Load via load_conf_file
- create new Configurable Class, use load_conf_file to load sample config
- check if sample config is loaded correctly

0 comments on commit dd46a5e

Please sign in to comment.