summaryrefslogtreecommitdiffstats
path: root/funcweb
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-21 16:47:00 +0300
committermakkalot <makkalot@gmail.com>2008-06-21 16:47:00 +0300
commit5c82990da0323d638b632152d1dc8ee338c16664 (patch)
tree3971d4a7274fdd0f9eabe7d4a793851749627395 /funcweb
parent4706ba8c79bfae2feb48fc7fd8b9bb7770077ae4 (diff)
downloadfunc-5c82990da0323d638b632152d1dc8ee338c16664.tar.gz
func-5c82990da0323d638b632152d1dc8ee338c16664.tar.xz
func-5c82990da0323d638b632152d1dc8ee338c16664.zip
the final validator hash is done with its tests , happy testing :)
Diffstat (limited to 'funcweb')
-rw-r--r--funcweb/funcweb/tests/test_widget_validation.py13
-rw-r--r--funcweb/funcweb/widget_validation.py15
2 files changed, 21 insertions, 7 deletions
diff --git a/funcweb/funcweb/tests/test_widget_validation.py b/funcweb/funcweb/tests/test_widget_validation.py
index 5cba250..adb4a15 100644
--- a/funcweb/funcweb/tests/test_widget_validation.py
+++ b/funcweb/funcweb/tests/test_widget_validation.py
@@ -90,11 +90,16 @@ class TestWidgetValidator(unittest.TestCase):
print "Happy test!"
- def test_list_validator(self):
- wf = WidgetSchemaFactory(self.get_list_params())
+ def test_list_validator(self,the_type='list'):
+ if the_type == 'list':
+ testing_data = self.get_list_params()
+ else:
+ testing_data = self.get_hash_params()
+
+ wf = WidgetSchemaFactory(testing_data)
schema_man=wf.get_ready_schema()
- for argument_name,arg_options in self.get_list_params().iteritems():
+ for argument_name,arg_options in testing_data.iteritems():
#print argument_name
#should all the argument names really
assert hasattr(schema_man,argument_name)==True
@@ -112,6 +117,8 @@ class TestWidgetValidator(unittest.TestCase):
print "Happy test!"
+ def test_hash_validator(self):
+ self.test_list_validator(the_type = 'hash')
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 61d6254..ae1203e 100644
--- a/funcweb/funcweb/widget_validation.py
+++ b/funcweb/funcweb/widget_validation.py
@@ -129,7 +129,7 @@ class WidgetSchemaFactory(object):
- def _add_list_validator(self,argument_name):
+ def _add_list_validator(self,argument_name,the_type='list'):
"""
Gets the options of the list type and adds a
new validator to validator_list
@@ -147,9 +147,16 @@ class WidgetSchemaFactory(object):
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)
+ if the_type == 'list':
+ self.validator_list[argument_name]=MinionListValidator(**list_data_set)
+ else:
+ self.validator_list[argument_name]=MinionHashValidator(**list_data_set)
+
else:
- self.validator_list[argument_name]=MinionListValidator()
+ if the_type == 'list':
+ self.validator_list[argument_name]=MinionListValidator()
+ else:
+ self.validator_list[argument_name]=MinionHashValidator()
@@ -158,7 +165,7 @@ class WidgetSchemaFactory(object):
Gets the options of the hash type and adds a
new validator to validator_list
"""
- pass
+ self._add_list_validator(argument_name,the_type = 'hash')
def get_ready_schema(self):