Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 8452)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 8467)
@@ -26,5 +26,5 @@
 import grok
 from zope.event import notify
-from zope.component import createObject, queryUtility, getUtility
+from zope.component import createObject, queryUtility
 from zope.component.hooks import setSite, clearSite
 from zope.catalog.interfaces import ICatalog
@@ -35,14 +35,16 @@
 from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
 from waeup.kofa.app import University
-from waeup.kofa.configuration import SessionConfiguration
 from waeup.kofa.students.student import Student
 from waeup.kofa.students.studylevel import StudentStudyLevel
 from waeup.kofa.university.faculty import Faculty
 from waeup.kofa.university.department import Department
-from waeup.kofa.interfaces import IUserAccount, IKofaUtils
+from waeup.kofa.interfaces import IUserAccount
 from waeup.kofa.authentication import LocalRoleSetEvent
 from waeup.kofa.hostels.hostel import Hostel, Bed, NOT_OCCUPIED
 
 PH_LEN = 2059  # Length of placeholder file
+
+SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
+SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp')
 
 def lookup_submit_value(name, value, browser):
@@ -522,8 +524,8 @@
         # as birth certificate
         self.browser.open(self.manage_clearance_path)
-        pseudo_image = StringIO('I pretend to be a graphics file')
+        image = open(SAMPLE_IMAGE, 'rb')
         ctrl = self.browser.getControl(name='birthcertificateupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
+        file_ctrl.add_file(image, filename='my_birth_certificate.jpg')
         # The Save action does not upload files
         self.browser.getControl("Save").click() # submit form
@@ -532,8 +534,8 @@
             in self.browser.contents)
         # ... but the correct upload submit button does
-        pseudo_image = StringIO('I pretend to be a graphics file')
+        image = open(SAMPLE_IMAGE)
         ctrl = self.browser.getControl(name='birthcertificateupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
+        file_ctrl.add_file(image, filename='my_birth_certificate.jpg')
         self.browser.getControl(
             name='upload_birthcertificateupload').click()
@@ -546,34 +548,32 @@
         self.assertEqual(
             self.browser.headers['content-type'], 'image/jpeg')
-        self.assertEqual(len(self.browser.contents), 31)
+        self.assertEqual(len(self.browser.contents), 2787)
         # Reuploading a file which is bigger than 150k will raise an error
         self.browser.open(self.manage_clearance_path)
-        photo_content = 'A' * 1024 * 151  # A string of 21 KB size
-        pseudo_image = StringIO(photo_content)
+        # An image > 150K
+        big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75)
         ctrl = self.browser.getControl(name='birthcertificateupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
+        file_ctrl.add_file(big_image, filename='my_birth_certificate.jpg')
         self.browser.getControl(
             name='upload_birthcertificateupload').click()
         self.assertTrue(
             'Uploaded file is too big' in self.browser.contents)
-        # File names must meet several conditions
-        pseudo_image = StringIO('I pretend to be a graphics file')
+        # we do not rely on filename extensions given by uploaders
+        image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
         ctrl = self.browser.getControl(name='birthcertificateupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my.photo.jpg')
+        # tell uploaded file is bmp
+        file_ctrl.add_file(image, filename='my_birth_certificate.bmp')
         self.browser.getControl(
             name='upload_birthcertificateupload').click()
-        self.assertTrue('File name contains more than one dot'
-            in self.browser.contents)
+        self.assertTrue(
+            # jpg file was recognized
+            'File birth_certificate.jpg uploaded.' in self.browser.contents)
+        # File names must meet several conditions
+        bmp_image = open(SAMPLE_IMAGE_BMP, 'rb')
         ctrl = self.browser.getControl(name='birthcertificateupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate')
-        self.browser.getControl(
-            name='upload_birthcertificateupload').click()
-        self.assertTrue('File name has no extension' in self.browser.contents)
-        ctrl = self.browser.getControl(name='birthcertificateupload')
-        file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.bmp')
+        file_ctrl.add_file(bmp_image, filename='my_birth_certificate.bmp')
         self.browser.getControl(
             name='upload_birthcertificateupload').click()
@@ -586,8 +586,8 @@
         # Managers can add and delete second file
         self.browser.open(self.manage_clearance_path)
-        pseudo_image = StringIO('I pretend to be a graphics file')
+        image = open(SAMPLE_IMAGE, 'rb')
         ctrl = self.browser.getControl(name='birthcertificateupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg')
+        file_ctrl.add_file(image, filename='my_acceptance_letter.jpg')
         self.browser.getControl(
             name='upload_acceptanceletterupload').click()
@@ -597,5 +597,6 @@
         ctrl = self.browser.getControl(name='acceptanceletterupload')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg')
+        image.seek(0)
+        file_ctrl.add_file(image, filename='my_acceptance_letter.jpg')
         self.browser.getControl(
             name='upload_acceptanceletterupload').click()
@@ -610,8 +611,8 @@
         # Managers can upload a file via the StudentBaseManageFormPage
         self.browser.open(self.manage_student_path)
-        pseudo_image = StringIO('I pretend to be a graphics file')
+        image = open(SAMPLE_IMAGE_BMP, 'rb')
         ctrl = self.browser.getControl(name='passportuploadmanage')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_photo.bmp')
+        file_ctrl.add_file(image, filename='my_photo.bmp')
         self.browser.getControl(
             name='upload_passportuploadmanage').click()
@@ -620,5 +621,6 @@
         ctrl = self.browser.getControl(name='passportuploadmanage')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_photo.jpg')
+        image = open(SAMPLE_IMAGE, 'rb')
+        file_ctrl.add_file(image, filename='my_photo.jpg')
         self.browser.getControl(
             name='upload_passportuploadmanage').click()
@@ -631,5 +633,6 @@
         self.browser.open(self.student_path + '/clearance.pdf')
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
+        self.assertEqual(self.browser.headers['Content-Type'],
+                         'application/pdf')
 
     def test_manage_course_lists(self):
@@ -1426,8 +1429,8 @@
         IWorkflowInfo(self.student).fireTransition('admit')
         self.browser.open(self.student_path + '/change_portrait')
-        pseudo_image = StringIO('I pretend to be a graphics file')
+        image = open(SAMPLE_IMAGE, 'rb')
         ctrl = self.browser.getControl(name='passportuploadedit')
         file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_image, filename='my_photo.jpg')
+        file_ctrl.add_file(image, filename='my_photo.jpg')
         self.browser.getControl(
             name='upload_passportuploadedit').click()
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py	(revision 8452)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py	(revision 8467)
@@ -130,9 +130,11 @@
 
     def create_passport_img(self, student):
-        # create some faked passport file for `student`
+        # create some passport file for `student`
         storage = getUtility(IExtFileStore)
+        image_path = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
+        self.image_contents = open(image_path, 'rb').read()
         file_id = IFileStoreNameChooser(student).chooseName(
             attr='passport.jpg')
-        storage.createFile(file_id, StringIO('I am a fake image.'))
+        storage.createFile(file_id, StringIO(self.image_contents))
 
     def test_backup_single_student_data(self):
@@ -144,5 +146,5 @@
         del_dir = self.app['datacenter'].deleted_path
         del_img_path = os.path.join(
-            del_dir, 'media', 'students', '00111', 'A111111',
+            del_dir, 'media', 'students', '00110', 'A111111',
             'passport_A111111.jpg')
 
@@ -151,5 +153,5 @@
         self.assertEqual(
             open(del_img_path, 'rb').read(),
-            'I am a fake image.')
+            self.image_contents)
 
         # The student data were put into CSV files
