Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 7082)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 7083)
@@ -661,4 +661,32 @@
         self.assertEqual(len(self.browser.contents), PH_LEN)
 
+    def test_uploaded_image_respects_file_size_restriction(self):
+        # When we upload an image that is too big ( > 10 KB) we will
+        # get an error message
+        self.login()
+        # Create a pseudo image file and select it to be uploaded in form
+        photo_content = 'A' * 1024 * 11  # A string of 11 GB size
+        pseudo_image = StringIO(photo_content)
+        ctrl = self.browser.getControl(name='form.passport')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(pseudo_image, filename='myphoto.jpg')
+        self.browser.getControl("Save").click() # submit form
+        # There is a correct <img> link included
+        self.assertTrue(
+            '<img src="passport.jpg" />' in self.browser.contents)
+        # We get a warning message
+        self.assertTrue(
+            'Uploaded image is too big' in self.browser.contents)
+        # Browsing the image gives us the default image, not the
+        # uploaded one.
+        self.browser.open(self.image_url('passport.jpg'))
+        self.assertEqual(
+            self.browser.headers['content-type'], 'image/jpeg')
+        self.assertEqual(len(self.browser.contents), PH_LEN)
+        # There is really no file stored for the applicant
+        img = getUtility(IExtFileStore).getFile(
+            IFileStoreNameChooser(self.applicant).chooseName())
+        self.assertTrue(img is None)
+
     def test_uploaded_image_browsable_w_errors(self):
         # We can upload a different image and browse it after submit,
