Ignore:
Timestamp:
21 Jul 2012, 16:41:08 (12 years ago)
Author:
Henrik Bettermann
Message:

Do not allow to upload file with filename which already exists in finished or unfinished folder.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py

    r9002 r9038  
    2626from zope.securitypolicy.interfaces import (
    2727    IPrincipalRoleMap, IPrincipalRoleManager)
     28from zope.testbrowser.testing import Browser
    2829from zope.interface.verify import verifyClass, verifyObject
    2930from waeup.kofa.interfaces import IBatchProcessor
     
    115116    def setUp(self):
    116117        super(TestFacultyProcessor, self).setUp()
     118
     119        self.browser = Browser()
     120        self.browser.handleErrors = False
     121        self.datacenter_path = 'http://localhost/app/datacenter'
     122        self.app['datacenter'].setStoragePath(self.dc_root)
    117123
    118124        self.proc = FacultyProcessor()
     
    284290        self.assertEqual(local_role, 'alfonsrole')
    285291        shutil.rmtree(os.path.dirname(fin_file))
     292        return
     293
     294    def test_upload_import_reupload(self):
     295        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     296        self.browser.open(self.datacenter_path)
     297        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     298        self.assertEqual(self.browser.url, self.datacenter_path)
     299        self.browser.getLink("Upload data").click()
     300        file = open(self.csv_file_faculty)
     301        ctrl = self.browser.getControl(name='uploadfile:file')
     302        file_ctrl = ctrl.mech_control
     303        file_ctrl.add_file(file, filename='sample_faculty_data.csv')
     304        self.browser.getControl('Upload').click()
     305        self.browser.getLink('Process data').click()
     306        self.browser.getControl(name="select").click()
     307        importerselect = self.browser.getControl(name='importer')
     308        importerselect.getControl('Faculty Processor').selected = True
     309        modeselect = self.browser.getControl(name='mode')
     310        modeselect.getControl(value='create').selected = True
     311        self.browser.getControl('Proceed to step 3').click()
     312        self.assertTrue('Header fields OK' in self.browser.contents)
     313        self.browser.getControl('Perform import').click()
     314        self.assertTrue('Successfully processed 1 rows' in self.browser.contents)
     315        # We import the same file a second time.
     316        self.browser.open(self.datacenter_path)
     317        self.browser.getLink("Upload data").click()
     318        file = open(self.csv_file_faculty)
     319        ctrl = self.browser.getControl(name='uploadfile:file')
     320        file_ctrl = ctrl.mech_control
     321        file_ctrl.add_file(file, filename='sample_faculty_data.csv')
     322        self.browser.getControl('Upload').click()
     323        self.assertTrue(
     324            'File with same name was uploaded earlier' in self.browser.contents)
    286325        return
    287326
Note: See TracChangeset for help on using the changeset viewer.