Commits

Anonymous committed 289187c

fixed broken tests

Comments (0)

Files changed (2)

pyramid_simpleform/__init__.py

             errors = [errors]
         return errors
 
-    def validate(self):
+    def validate(self, force_validate=False, params=None):
         """
         Runs validation and returns True/False whether form is 
         valid.
         if self.is_validated:
             return not(self.errors)
 
-        if self.method and self.method != self.request.method:
-            return False
+        if not force_validate:
+            if self.method and self.method != self.request.method:
+                return False
 
-        if self.method == "POST":
-            params = self.request.POST
-        else:
-            params = self.request.params
-        
+        if params is None:
+            if self.method == "POST":
+                params = self.request.POST
+            else:
+                params = self.request.params
+            
         self.data.update(params)
 
         try:
-            self.data = self.schema.serialize(params)
+            self.data = self.schema.deserialize(params)
         except colander.Invalid, e:
             self.errors = e.asdict()
 

pyramid_simpleform/tests.py

                                validator=colander.Length(min=1))
 
 
-
 class SimpleObj(object):
 
     def __init__(self, name=None):
         self.assert_(form.is_validated)
         self.assert_('name' in form.errors)
 
-        self.assert_(form.errors_for('name') == ['Missing value'])
-
+        self.assert_(form.errors_for('name') == ['Required'])
 
     def test_validate_twice(self):
         
         self.assert_(not(form.validate()))
         renderer = FormRenderer(form)
 
-        self.assert_(renderer.errors_for('name') == ['Missing value'])
+        self.assert_(renderer.errors_for('name') == ['Required'])
 
     def test_errorlist(self):
 
         renderer = FormRenderer(form)
 
         self.assert_(renderer.errorlist() == \
-                     '<ul class="error"><li>Missing value</li></ul>')
+                     '<ul class="error"><li>Required</li></ul>')
      
 
     def test_errorlist_with_no_errors(self):
         renderer = FormRenderer(form)
 
         self.assert_(renderer.errorlist('name') == \
-                     '<ul class="error"><li>Missing value</li></ul>')
+                     '<ul class="error"><li>Required</li></ul>')
  
     def test_label(self):
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.