Index: main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/fileviewlets.py
===================================================================
--- main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/fileviewlets.py	(revision 12381)
+++ main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/fileviewlets.py	(revision 12382)
@@ -79,45 +79,2 @@
     grok.view(PDFDocumentSlipPage)
 
-
-class PDFScanManageUpload(FileUpload):
-    """Scan upload viewlet for officers.
-    """
-    grok.view(DocumentManageFormPage)
-    grok.context(SkeletonCustomerDocument)
-    grok.require('waeup.manageCustomer')
-    label = _(u'PDF File')
-    title = _(u'PDF File')
-    mus = 1024 * 200
-    download_name = u'sample.pdf'
-    tab_redirect = '#tab2'
-
-
-class PDFScanEditUpload(PDFScanManageUpload):
-    """Scan upload viewlet for customer.
-    """
-    grok.view(DocumentEditFormPage)
-    grok.require('waeup.handleCustomer')
-
-
-class PDFScanDisplay(FileDisplay):
-    """Scan display viewlet.
-    """
-    grok.order(1)
-    grok.context(SkeletonCustomerDocument)
-    grok.require('waeup.viewCustomer')
-    grok.view(DocumentDisplayFormPage)
-    label = _(u'PDF Scan')
-    title = _(u'PDF Scan')
-    download_name = u'sample.pdf'
-
-
-class PDFScanImage(Image):
-    """Scan document.
-    """
-    grok.name('sample.pdf')
-    grok.context(SkeletonCustomerDocument)
-    grok.require('waeup.viewCustomer')
-    download_name = u'sample.pdf'
-
-class PDFScanSlip(PDFScanDisplay):
-    grok.view(PDFDocumentSlipPage)
Index: main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/tests/test_browser.py
===================================================================
--- main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/tests/test_browser.py	(revision 12381)
+++ main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/tests/test_browser.py	(revision 12382)
@@ -213,44 +213,75 @@
     layer = FunctionalLayer
 
-    def test_manage_upload_pdf_file(self):
+    def test_manage_upload_sample_file(self):
         # Managers can upload a file via the DocumentManageFormPage
         # The image is stored even if form has errors
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
-        self.browser.open(self.customer_path + '/documents')
-        self.browser.getControl("Add document").click()
-        self.browser.getControl(name="doctype").value = ['SkeletonCustomerDocument']
-        self.browser.getControl(name="form.title").value = 'My Skeleton Document'
-        self.browser.getControl("Add document").click()
-        docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
-        self.browser.open(self.documents_path + '/%s/manage' % docid)
+        self.browser.open(self.customer_path + '/documents/DOC1/manage')
         # Create a pseudo image file and select it to be uploaded
         image = open(SAMPLE_IMAGE, 'rb')
-        ctrl = self.browser.getControl(name='pdfscanmanageupload')
+        ctrl = self.browser.getControl(name='samplescanmanageupload')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
+        # The Save action does not upload files
+        self.browser.getControl("Save").click() # submit form
+        self.assertFalse(
+            'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"'
+            in self.browser.contents)
+        # ... but the correct upload submit button does
+        image = open(SAMPLE_IMAGE)
+        ctrl = self.browser.getControl(name='samplescanmanageupload')
         file_ctrl = ctrl.mech_control
         file_ctrl.add_file(image, filename='my_sample_scan.jpg')
         self.browser.getControl(
-            name='upload_pdfscanmanageupload').click()
-        self.assertTrue(
-            'pdf file extension expected' in self.browser.contents)
-        ctrl = self.browser.getControl(name='pdfscanmanageupload')
-        file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(image, filename='my_sample_scan.pdf')
+            name='upload_samplescanmanageupload').click()
+        self.assertTrue(
+            'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"'
+            in self.browser.contents)
+        # Browsing the link shows a real image
+        self.browser.open('sample')
+        self.assertEqual(
+            self.browser.headers['content-type'], 'image/jpeg')
+        self.assertEqual(len(self.browser.contents), 2787)
+        # We can't reupload a file. The existing file must be deleted first.
+        self.browser.open(self.customer_path + '/documents/DOC1/manage')
+        self.assertFalse(
+            'upload_samplescanmanageupload' in self.browser.contents)
+        # File must be deleted first
+        self.browser.getControl(name='delete_samplescanmanageupload').click()
+        self.assertTrue(
+            'sample deleted' in self.browser.contents)
+        # Uploading a file which is bigger than 150k will raise an error
+        big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75)
+        ctrl = self.browser.getControl(name='samplescanmanageupload')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(big_image, filename='my_sample_scan.jpg')
         self.browser.getControl(
-            name='upload_pdfscanmanageupload').click()
-        self.assertTrue(
-            'Could not determine file type' in self.browser.contents)
-        pdf = open(SAMPLE_PDF, 'rb')
-        ctrl = self.browser.getControl(name='pdfscanmanageupload')
-        file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pdf, filename='my_sample_scan.pdf')
+            name='upload_samplescanmanageupload').click()
+        self.assertTrue(
+            'Uploaded file is too big' in self.browser.contents)
+        # We do not rely on filename extensions given by uploaders
+        image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
+        ctrl = self.browser.getControl(name='samplescanmanageupload')
+        file_ctrl = ctrl.mech_control
+        # Tell uploaded file is bmp
+        file_ctrl.add_file(image, filename='my_sample_scan.bmp')
         self.browser.getControl(
-            name='upload_pdfscanmanageupload').click()
-        self.assertTrue(
-            'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">PDF File</a>'
-            % docid in self.browser.contents)
-        # Browsing the link shows a real pdf
-        self.browser.open('sample.pdf')
-        self.assertEqual(
-            self.browser.headers['content-type'], 'application/pdf')
+            name='upload_samplescanmanageupload').click()
+        self.assertTrue(
+            # jpg file was recognized
+            'File sample.jpg uploaded.' in self.browser.contents)
+        # Delete file again
+        self.browser.getControl(name='delete_samplescanmanageupload').click()
+        self.assertTrue(
+            'sample deleted' in self.browser.contents)
+        # File names must meet several conditions
+        bmp_image = open(SAMPLE_IMAGE_BMP, 'rb')
+        ctrl = self.browser.getControl(name='samplescanmanageupload')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(bmp_image, filename='my_sample_scan.bmp')
+        self.browser.getControl(
+            name='upload_samplescanmanageupload').click()
+        self.assertTrue('Only the following extensions are allowed'
+            in self.browser.contents)
 
 class ContractUITests(CustomersFullSetup):
