Changeset 14939 for main/waeup.kofa/trunk/src/waeup/kofa/browser
- Timestamp:
- 18 Jan 2018, 07:34:42 (7 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/browser
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r14648 r14939 1345 1345 invalid_line = check_csv_charset(filecontent.splitlines()) 1346 1346 if invalid_line: 1347 self.flash(_( 1348 "Your file contains forbidden characters or " 1349 "has invalid CSV format. " 1350 "First problematic line detected: line %s. " 1351 "Please replace." % invalid_line), type='danger') 1347 if invalid_line == -1: 1348 self.flash(_( 1349 "The data in your file contain trailing whitespaces." 1350 "Please replace."), type='danger') 1351 else: 1352 self.flash(_( 1353 "Your file contains forbidden characters or " 1354 "has invalid CSV format. " 1355 "First problematic line detected: line %s. " 1356 "Please replace." % invalid_line), type='danger') 1352 1357 logger.info('%s - invalid file uploaded: %s' % 1353 1358 (ob_class, target)) -
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r14511 r14939 40 40 SAMPLE_FILE = os.path.join(os.path.dirname(__file__), 'test_file.csv') 41 41 FORBIDDEN_FILE = os.path.join(os.path.dirname(__file__), 'forbidden_file.csv') 42 FORBIDDEN_FILE_2 = os.path.join( 43 os.path.dirname(__file__), 'forbidden_file_2.csv') 42 44 43 45 class UniversitySetup(FunctionalTestCase): … … 193 195 self.assertTrue( 194 196 'Your file contains forbidden characters or' 197 in self.browser.contents) 198 logfile = os.path.join( 199 self.app['datacenter'].storage, 'logs', 'datacenter.log') 200 logcontent = open(logfile).read() 201 self.assertTrue('zope.mgr - browser.pages.DatacenterUploadPage - ' 202 'invalid file uploaded:' in logcontent) 203 return 204 205 def test_forbidden_file_upload_2(self): 206 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 207 self.browser.open(self.datacenter_path) 208 self.assertEqual(self.browser.headers['Status'], '200 Ok') 209 self.assertEqual(self.browser.url, self.datacenter_path) 210 self.browser.getLink("Upload data").click() 211 file = open(FORBIDDEN_FILE_2) 212 ctrl = self.browser.getControl(name='uploadfile:file') 213 file_ctrl = ctrl.mech_control 214 file_ctrl.add_file(file, filename='my_corrupted_file.csv') 215 self.browser.getControl('Upload').click() 216 self.assertTrue( 217 'The data in your file contain trailing whitespaces.' 195 218 in self.browser.contents) 196 219 logfile = os.path.join(
Note: See TracChangeset for help on using the changeset viewer.