Changeset 8999 for main/waeup.kofa/trunk/src
- Timestamp:
- 13 Jul 2012, 14:42:44 (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
r8998 r8999 44 44 '\n')[0].split(',') 45 45 46 DEPARTMENT_SAMPLE_DATA = open( 47 os.path.join(os.path.dirname(__file__), 'sample_department_data.csv'), 48 'rb').read() 49 50 DEPARTMENT_HEADER_FIELDS = DEPARTMENT_SAMPLE_DATA.split( 51 '\n')[0].split(',') 52 46 53 class UniversityProcessorSetup(FunctionalTestCase): 47 54 … … 58 65 59 66 self.app['users'].addUser('bob', 'bobssecret') 67 self.app['users'].addUser('anne', 'annessecret') 60 68 61 69 # Populate university … … 211 219 self.site3 = dict(faculties=dict(FAC=dict(DPT='pseudo department'))) 212 220 self.row = dict(code='DPT', faculty_code='FAC') 221 222 self.csv_file_department = os.path.join(self.workdir, 'sample_department_data.csv') 223 open(self.csv_file_department, 'wb').write(DEPARTMENT_SAMPLE_DATA) 213 224 return 214 225 … … 256 267 self.assertTrue('DPT' not in self.site3['faculties']['FAC'].keys()) 257 268 return 269 270 def test_import(self): 271 num, num_warns, fin_file, fail_file = self.proc.doImport( 272 self.csv_file_department, DEPARTMENT_HEADER_FIELDS) 273 content = open(fail_file).read() 274 self.assertEqual(num_warns,6) 275 self.assertEqual( 276 content, 277 'faculty_code,code,local_roles,--ERRORS--\r\n' 278 'FAC1,DEP2,"[{\'user_name\':\'alice\',\'local_role\':\'waeup.local.DepartmentManager\'}]",' 279 'local_roles: alice does not exist\r\n' 280 'FAC1,DEP2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.Boss\'}]",' 281 'local_roles: waeup.local.Boss not allowed\r\n' 282 'FAC1,DEP2,[(\'anything\')],local_roles: no dicts\r\n' 283 'FAC1,DEP2,[,local_roles: Error\r\n' 284 'FAC1,DEP2,"[{\'user\':\'anne\',\'local\':\'waeup.local.DepartmentManager\'}]",' 285 'local_roles: user_name or local_role missing\r\n' 286 'FAC11,DEP2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.DepartmentManager\'}]",' 287 'Not all parents do exist yet. Skipping\r\n' 288 ) 289 # Bob got a local role in department ABC. 290 dep = self.app['faculties']['FAC1']['DEP2'] 291 role_map = IPrincipalRoleMap(dep) 292 local_role, user_name, setting = role_map.getPrincipalsAndRoles()[0] 293 self.assertEqual(user_name, 'anne') 294 self.assertEqual(local_role, 'waeup.local.DepartmentManager') 295 shutil.rmtree(os.path.dirname(fin_file)) 258 296 259 297 class CourseProcessorTests(UniversityProcessorSetup):
Note: See TracChangeset for help on using the changeset viewer.