damned-lies r1255 - in trunk: . vertimus vertimus/tests



Author: claudep
Date: Mon Dec 29 21:22:16 2008
New Revision: 1255
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1255&view=rev

Log:
2008-12-29  Claude Paroz  <claude 2xlibre net>

	* vertimus/forms.py: Fix clean_file when there is no file.
	* vertimus/tests/__init__.py: Add test when no file is submitted.

Modified:
   trunk/ChangeLog
   trunk/vertimus/forms.py
   trunk/vertimus/tests/__init__.py

Modified: trunk/vertimus/forms.py
==============================================================================
--- trunk/vertimus/forms.py	(original)
+++ trunk/vertimus/forms.py	Mon Dec 29 21:22:16 2008
@@ -43,10 +43,12 @@
 
     def clean_file(self):
         data = self.cleaned_data['file']
-        ext = os.path.splitext(data.name)[1]
-        # If this is a .po file, check validity (msgfmt)
-        if ext == ".po":
-            res = po_file_stats(data)
-            if res['errors']:
-                raise forms.ValidationError(".po file does not pass 'msgfmt -vc'. Please correct the file and try again.")
+        if data:
+            ext = os.path.splitext(data.name)[1]
+            # If this is a .po file, check validity (msgfmt)
+            if ext == ".po":
+                res = po_file_stats(data)
+                if res['errors']:
+                    raise forms.ValidationError(".po file does not pass 'msgfmt -vc'. Please correct the file and try again.")
+        return data
 

Modified: trunk/vertimus/tests/__init__.py
==============================================================================
--- trunk/vertimus/tests/__init__.py	(original)
+++ trunk/vertimus/tests/__init__.py	Mon Dec 29 21:22:16 2008
@@ -404,4 +404,8 @@
         form = ActionForm([('WC', u'Write a comment')], post_content, post_file)
 
         self.assert_(form.is_valid())
+        
+        # Test form without file
+        form = ActionForm([('WC', u'Write a comment')], post_content)
+        self.assert_(form.is_valid())
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]