Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added test suite for Configurable Class

  • Loading branch information...
commit dd46a5e0f2a67cf353565f27644ee98a2b4a8adf 1 parent c808c10
authored February 01, 2011
2  genericore/utils.py
@@ -36,8 +36,6 @@ def load_conf_file(self,config_file):
36 36
     with open(config_file) as f:
37 37
       new_conf = json.load(f,encoding='ascii')
38 38
       self.load_conf(new_conf)
39  
-    def load_conf_parser(self,parser):
40  
-      """ loads the configuration from a parser object """
41 39
 
42 40
 class Configurator(Configurable):
43 41
   def __init__(self,PROTO_VERSION=1,DESCRIPTION='description not set!',conf=None):
25  tests/config_test.py
... ...
@@ -0,0 +1,25 @@
  1
+from genericore import Configurable
  2
+
  3
+def test_loadConstructor():
  4
+  class cl(Configurable): pass
  5
+  conf = {'a' : 'b'}
  6
+  a = cl(conf)
  7
+  assert a.config['a'] == 'b'
  8
+
  9
+def test_load_conf():
  10
+  a = Configurable({'a' : 'b'})
  11
+  assert a.config['a'] == 'b'
  12
+
  13
+  a.load_conf({'a' : { 'x' : 'y'}})
  14
+  assert a.config['a']['x'] == 'y'
  15
+
  16
+  a.load_conf({'b' : 'd'})
  17
+  assert a.config['a']['x'] == 'y'
  18
+  assert a.config['b'] == 'd'
  19
+
  20
+def test_load_conf_file():
  21
+  a = Configurable({'a' : {'x' : 'y'}})
  22
+  a.load_conf_file('configurable.json')
  23
+  assert a.config['a']['x'] == 'z'
  24
+  assert a.config['b'] == 'd'
  25
+  
4  tests/configurable.json
... ...
@@ -0,0 +1,4 @@
  1
+{
  2
+  "a" : { "x" : "z"},
  3
+  "b" : "d"
  4
+}
6  tests/genericore.tests
... ...
@@ -1,13 +1,13 @@
1 1
 Test Cases
2 2
 ==========
3 3
 1. Configurable
4  
-1.1. Load via Constructor
  4
+(x) 1.1. Load via Constructor  
5 5
   - create new class and derive from Configurable
6 6
   - Check if sample config is loaded correctly
7  
-1.2 Load via load_conf
  7
+(x) 1.2 Load via load_conf
8 8
   - create new class, use load_conf
9 9
   - check if sample config is loaded correctly
10  
-1.3 Load via load_conf_file
  10
+(x) 1.3 Load via load_conf_file
11 11
   - create new Configurable Class, use load_conf_file to load sample config
12 12
   - check if sample config is loaded correctly
13 13
 

0 notes on commit dd46a5e

Please sign in to comment.
Something went wrong with that request. Please try again.