summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-21 11:59:35 +0300
committermakkalot <makkalot@gmail.com>2008-06-21 11:59:35 +0300
commitde503d14a2239fd38f377ae7bf613e553aa2fd8f (patch)
tree2f33ac3e7fd46479a5f60182aabe5d1557f24beb
parent056714c8566d028ccab6d217a615d9a14e185b58 (diff)
downloadthird_party-func-de503d14a2239fd38f377ae7bf613e553aa2fd8f.tar.gz
third_party-func-de503d14a2239fd38f377ae7bf613e553aa2fd8f.tar.xz
third_party-func-de503d14a2239fd38f377ae7bf613e553aa2fd8f.zip
adding list factory validator, the process becomes easier :)
-rw-r--r--funcweb/funcweb/tests/test_widget_validation.py22
-rw-r--r--funcweb/funcweb/widget_validation.py19
2 files changed, 40 insertions, 1 deletions
diff --git a/funcweb/funcweb/tests/test_widget_validation.py b/funcweb/funcweb/tests/test_widget_validation.py
index e501b53..6b33008 100644
--- a/funcweb/funcweb/tests/test_widget_validation.py
+++ b/funcweb/funcweb/tests/test_widget_validation.py
@@ -90,6 +90,28 @@ class TestWidgetValidator(unittest.TestCase):
print "Happy test!"
+ def test_list_validator(self):
+ wf = WidgetSchemaFactory(self.get_list_params())
+ schema_man=wf.get_ready_schema()
+
+ for argument_name,arg_options in self.get_list_params().iteritems():
+ #print argument_name
+ #should all the argument names really
+ assert hasattr(schema_man,argument_name)==True
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+
+ if arg_options.has_key('validator'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert getattr(getattr(schema_man,argument_name),'regex_string') == arg_options['validator']
+
+ if arg_options.has_key('optional'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert not getattr(getattr(schema_man,argument_name),'not_empty') == arg_options['optional']
+
+
+ print "Happy test!"
+
+
def test_minion_int_validator(self):
mv=MinionIntValidator(max = 44,min=2)
diff --git a/funcweb/funcweb/widget_validation.py b/funcweb/funcweb/widget_validation.py
index 0f908a8..964a159 100644
--- a/funcweb/funcweb/widget_validation.py
+++ b/funcweb/funcweb/widget_validation.py
@@ -134,7 +134,24 @@ class WidgetSchemaFactory(object):
Gets the options of the list type and adds a
new validator to validator_list
"""
- pass
+ list_data_set = {}
+
+ #is it optional
+ if self.method_argument_dict[argument_name].has_key('optional'):
+ if self.method_argument_dict[argument_name]['optional']:
+ list_data_set['not_empty']=False
+ else:
+ list_data_set['not_empty']=True
+
+ if self.method_argument_dict[argument_name].has_key('validator'):
+ list_data_set['regex_string'] = self.method_argument_dict[argument_name]['validator']
+
+ if list_data_set:
+ self.validator_list[argument_name]=MinionListValidator(**list_data_set)
+ else:
+ self.validator_list[argument_name]=MinionListValidator()
+
+
def _add_hash_validator(self,argument_name):
"""