Changeset 9038
- Timestamp:
- 21 Jul 2012, 16:41:08 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r9033 r9038 844 844 self.flash(_("Only csv files are allowed.")) 845 845 return 846 target = os.path.join(self.context.storage, 847 self.getNormalizedFileName(filename)) 846 normalized_filename = self.getNormalizedFileName(filename) 847 finished_file = os.path.join( 848 self.context.storage, 'finished', normalized_filename) 849 unfinished_file = os.path.join( 850 self.context.storage, 'unfinished', normalized_filename) 851 if os.path.exists(finished_file) or os.path.exists(unfinished_file): 852 self.flash(_("File with same name was uploaded earlier.")) 853 return 854 target = os.path.join(self.context.storage, normalized_filename) 848 855 open(target, 'wb').write(uploadfile.read()) 849 856 os.chmod(target, 0664) -
main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py
r9002 r9038 26 26 from zope.securitypolicy.interfaces import ( 27 27 IPrincipalRoleMap, IPrincipalRoleManager) 28 from zope.testbrowser.testing import Browser 28 29 from zope.interface.verify import verifyClass, verifyObject 29 30 from waeup.kofa.interfaces import IBatchProcessor … … 115 116 def setUp(self): 116 117 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) 117 123 118 124 self.proc = FacultyProcessor() … … 284 290 self.assertEqual(local_role, 'alfonsrole') 285 291 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) 286 325 return 287 326
Note: See TracChangeset for help on using the changeset viewer.