summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-20 14:10:58 +0300
committermakkalot <makkalot@gmail.com>2008-06-20 14:10:58 +0300
commita947dfa3a910fbb8fe2b5dce9c7c150abd910790 (patch)
tree35643ece9e27c3e17dae777896b824793dd8c6ad
parent5d33994f135e1d92c5a5fceb50b7698bb9e9e6e4 (diff)
downloadfunc-a947dfa3a910fbb8fe2b5dce9c7c150abd910790.tar.gz
func-a947dfa3a910fbb8fe2b5dce9c7c150abd910790.tar.xz
func-a947dfa3a910fbb8fe2b5dce9c7c150abd910790.zip
add integer validation factory test part
-rw-r--r--funcweb/funcweb/tests/test_widget_validation.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/funcweb/funcweb/tests/test_widget_validation.py b/funcweb/funcweb/tests/test_widget_validation.py
index d9e2d8c..afb8fd6 100644
--- a/funcweb/funcweb/tests/test_widget_validation.py
+++ b/funcweb/funcweb/tests/test_widget_validation.py
@@ -37,6 +37,30 @@ class TestWidgetValidator(unittest.TestCase):
continue
print "Happy tests !"
+ def test_int_validator(self):
+ wf = WidgetSchemaFactory(self.get_int_params())
+ schema_man=wf.get_ready_schema()
+
+ for argument_name,arg_options in self.get_int_params().iteritems():
+ #print argument_name
+ assert hasattr(schema_man,argument_name)==True
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+
+ #if the argument includes some range
+ if arg_options.has_key('range'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert getattr(getattr(schema_man,argument_name),'max_int') == arg_options['range'][1]
+ assert getattr(getattr(schema_man,argument_name),'min_int') == arg_options['range'][0]
+ if arg_options.has_key('min'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert getattr(getattr(schema_man,argument_name),'min_int') == arg_options['min']
+
+ if arg_options.has_key('max'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert getattr(getattr(schema_man,argument_name),'max_int') == arg_options['max']
+
+ print "Happy test!"
+
def test_minion_int_validator(self):
mv=MinionIntValidator(max_int = 44,min_int=2)
@@ -76,7 +100,6 @@ class TestWidgetValidator(unittest.TestCase):
'validator':'^[a-z]*$'
}
,
- #will be converted to dropdown
'min_max_string':{
'type':'string',
'default':'myfirst',
@@ -93,4 +116,26 @@ class TestWidgetValidator(unittest.TestCase):
'validator':'^[A-Z]+$'
}
}
+
+ def get_int_params(self):
+ return {
+ 'int_default':{
+ 'type':'int',
+ 'default':2,
+ 'description':'default integer'
+ },
+ 'min_max_int':{
+ 'type':'int',
+ 'default':12,
+ 'optional':False,
+ 'description':'default dropdown list',
+ 'max':12,
+ 'min':5
+ },
+ 'range_int':{
+ 'type':'int',
+ 'optional':False,
+ 'range':[1,55]
+ }
+ }