Changeset 8995 for main/waeup.kofa/trunk/src/waeup/kofa/university/tests
- Timestamp:
- 13 Jul 2012, 08:18:02 (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
r8994 r8995 21 21 import tempfile 22 22 import shutil 23 import os 23 24 from zope.component.hooks import setSite, clearSite 25 from zope.securitypolicy.interfaces import IPrincipalRoleMap 24 26 from zope.interface.verify import verifyClass, verifyObject 25 27 from waeup.kofa.interfaces import IBatchProcessor … … 34 36 from waeup.kofa.university.batching import FacultyProcessor 35 37 38 FACULTY_SAMPLE_DATA = open( 39 os.path.join(os.path.dirname(__file__), 'sample_faculty_data.csv'), 40 'rb').read() 41 42 FACULTY_HEADER_FIELDS = FACULTY_SAMPLE_DATA.split( 43 '\n')[0].split(',') 36 44 37 45 class TestFacultyProcessor(FunctionalTestCase): … … 54 62 self.site2 = dict(faculties=dict(FAC='pseudo faculty')) 55 63 self.row = dict(code='FAC') 64 56 65 self.processor = FacultyProcessor() 66 self.csv_file_faculty = os.path.join(self.workdir, 'sample_faculty_data.csv') 67 open(self.csv_file_faculty, 'wb').write(FACULTY_SAMPLE_DATA) 57 68 return 58 69 … … 144 155 self.assertEqual(len(errs),0) 145 156 return 157 158 def test_import(self): 159 num, num_warns, fin_file, fail_file = self.processor.doImport( 160 self.csv_file_faculty, FACULTY_HEADER_FIELDS) 161 content = open(fail_file).read() 162 self.assertEqual(num_warns,5) 163 self.assertEqual( 164 content, 165 'code,local_roles,--ERRORS--\r\n' 166 'CDE,"[{\'user_name\':\'alice\',\'local_role\':\'waeup.local.DepartmentManager\'}]",' 167 'local_roles: alice does not exist\r\n' 168 'DEF,"[{\'user_name\':\'bob\',\'local_role\':\'waeup.local.Boss\'}]",' 169 'local_roles: waeup.local.Boss not allowed\r\n' 170 'EFG,[(\'anything\')],local_roles: no dicts\r\n' 171 'FGH,[,local_roles: Error\r\n' 172 'GHI,"[{\'user\':\'bob\',\'local\':\'waeup.local.DepartmentManager\'}]",' 173 'local_roles: user_name or local_role missing\r\n' 174 ) 175 # Bob got a local role in faculty ABC. 176 abc = self.app['faculties']['ABC'] 177 role_map = IPrincipalRoleMap(abc) 178 local_role, user_name, setting = role_map.getPrincipalsAndRoles()[0] 179 self.assertEqual(user_name, 'bob') 180 self.assertEqual(local_role, 'waeup.local.DepartmentManager') 181 shutil.rmtree(os.path.dirname(fin_file)) 146 182 147 183 class TestDepartmentProcessors(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.