Changeset 9000 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 13 Jul 2012, 15:07:19 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/university/tests
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py
r8999 r9000 49 49 50 50 DEPARTMENT_HEADER_FIELDS = DEPARTMENT_SAMPLE_DATA.split( 51 '\n')[0].split(',') 52 53 CERTIFICATE_SAMPLE_DATA = open( 54 os.path.join(os.path.dirname(__file__), 'sample_certificate_data.csv'), 55 'rb').read() 56 57 CERTIFICATE_HEADER_FIELDS = CERTIFICATE_SAMPLE_DATA.split( 51 58 '\n')[0].split(',') 52 59 … … 208 215 self.assertEqual(local_role, 'waeup.local.DepartmentManager') 209 216 shutil.rmtree(os.path.dirname(fin_file)) 217 return 210 218 211 219 class TestDepartmentProcessor(UniversityProcessorSetup): … … 287 295 'Not all parents do exist yet. Skipping\r\n' 288 296 ) 289 # Bobgot a local role in department ABC.297 # Anne got a local role in department ABC. 290 298 dep = self.app['faculties']['FAC1']['DEP2'] 291 299 role_map = IPrincipalRoleMap(dep) … … 294 302 self.assertEqual(local_role, 'waeup.local.DepartmentManager') 295 303 shutil.rmtree(os.path.dirname(fin_file)) 304 return 296 305 297 306 class CourseProcessorTests(UniversityProcessorSetup): … … 358 367 self.row3 = dict(department_code='DEP1', faculty_code='FAC1', code="CRT2") 359 368 self.row4 = dict(department_code='DEP1', faculty_code='FAC1', code="CRT1") 369 370 self.csv_file_certificate = os.path.join(self.workdir, 'sample_certificate_data.csv') 371 open(self.csv_file_certificate, 'wb').write(CERTIFICATE_SAMPLE_DATA) 360 372 return 361 373 … … 401 413 self.proc.delEntry(self.row4, self.app) 402 414 self.assertTrue('CRT1' not in self.app['faculties']['FAC1']['DEP1'].certificates.keys()) 415 return 416 417 def test_import(self): 418 num, num_warns, fin_file, fail_file = self.proc.doImport( 419 self.csv_file_certificate, CERTIFICATE_HEADER_FIELDS) 420 content = open(fail_file).read() 421 self.assertEqual(num_warns,6) 422 self.assertEqual( 423 content, 424 'faculty_code,department_code,code,local_roles,--ERRORS--\r\n' 425 'FAC1,DEP1,CRT2,"[{\'user_name\':\'alice\',\'local_role\':\'waeup.local.CourseAdviser100\'}]",' 426 'local_roles: alice does not exist\r\n' 427 'FAC1,DEP1,CRT2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.Boss\'}]",' 428 'local_roles: waeup.local.Boss not allowed\r\n' 429 'FAC1,DEP1,CRT2,[(\'anything\')],local_roles: no dicts\r\n' 430 'FAC1,DEP1,CRT2,[,local_roles: Error\r\n' 431 'FAC1,DEP1,CRT2,"[{\'user\':\'anne\',\'local\':\'waeup.local.CourseAdviser100\'}]",' 432 'local_roles: user_name or local_role missing\r\n' 433 'FAC11,DEP2,CRT2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.CourseAdviser100\'}]",' 434 'Not all parents do exist yet. Skipping\r\n' 435 ) 436 # Anne got a local role in certificate ABC. 437 dep = self.app['faculties']['FAC1']['DEP1'].certificates['CRT2'] 438 role_map = IPrincipalRoleMap(dep) 439 local_role, user_name, setting = role_map.getPrincipalsAndRoles()[0] 440 self.assertEqual(user_name, 'anne') 441 self.assertEqual(local_role, 'waeup.local.CourseAdviser100') 442 shutil.rmtree(os.path.dirname(fin_file)) 403 443 return 404 444
Note: See TracChangeset for help on using the changeset viewer.