Changeset 8994 for main/waeup.kofa/trunk/src/waeup/kofa/university/tests
- Timestamp:
- 13 Jul 2012, 06:09:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py
r8920 r8994 19 19 # Tests for university related batching 20 20 import unittest 21 21 import tempfile 22 import shutil 23 from zope.component.hooks import setSite, clearSite 22 24 from zope.interface.verify import verifyClass, verifyObject 23 25 from waeup.kofa.interfaces import IBatchProcessor 24 26 from waeup.kofa.testing import FunctionalTestCase, FunctionalLayer 27 from waeup.kofa.app import University 25 28 from waeup.kofa.university.batching import ( 26 29 FacultyProcessor, DepartmentProcessor, CourseProcessor, … … 29 32 from waeup.kofa.university.course import Course 30 33 from waeup.kofa.university.department import Department 31 32 33 class TestFacultyProcessor(unittest.TestCase): 34 from waeup.kofa.university.batching import FacultyProcessor 35 36 37 class TestFacultyProcessor(FunctionalTestCase): 38 39 layer = FunctionalLayer 34 40 35 41 def setUp(self): 42 super(TestFacultyProcessor, self).setUp() 43 self.dc_root = tempfile.mkdtemp() 44 self.workdir = tempfile.mkdtemp() 45 app = University() 46 self.getRootFolder()['app'] = app 47 self.app = self.getRootFolder()['app'] 48 setSite(app) 49 50 self.app['users'].addUser('bob', 'bobssecret') 51 36 52 self.proc = FacultyProcessor() 37 53 self.site1 = dict(faculties=dict()) 38 54 self.site2 = dict(faculties=dict(FAC='pseudo faculty')) 39 55 self.row = dict(code='FAC') 56 self.processor = FacultyProcessor() 57 return 58 59 def tearDown(self): 60 super(TestFacultyProcessor, self).tearDown() 61 shutil.rmtree(self.workdir) 62 shutil.rmtree(self.dc_root) 63 clearSite() 40 64 return 41 65 … … 58 82 self.proc.delEntry(self.row, self.site2) 59 83 self.assertTrue('FAC' not in self.site2.keys()) 84 return 85 86 def test_checkConversion(self): 87 # Make sure we can check conversions. 88 errs, inv_errs, conv_dict = self.processor.checkConversion( 89 dict(faculty_code='ABC', local_roles='[]')) 90 self.assertEqual(len(errs),0) 91 92 errs, inv_errs, conv_dict = self.processor.checkConversion( 93 dict(faculty_code='ABC', 94 local_roles="['nonsense'" 95 )) 96 self.assertEqual(len(errs),1) 97 self.assertEqual(errs, [('local_roles', 'Error')]) 98 errs, inv_errs, conv_dict = self.processor.checkConversion( 99 dict(faculty_code='ABC', 100 local_roles="('abc')" 101 )) 102 self.assertEqual(len(errs),1) 103 self.assertEqual(errs, [('local_roles', 'no list')]) 104 errs, inv_errs, conv_dict = self.processor.checkConversion( 105 dict(faculty_code='ABC', 106 local_roles="[('ABC')]" 107 )) 108 self.assertEqual(len(errs),1) 109 self.assertEqual(errs, [('local_roles', 'no dicts')]) 110 errs, inv_errs, conv_dict = self.processor.checkConversion( 111 dict(faculty_code='ABC', 112 local_roles="('abc')" 113 )) 114 self.assertEqual(len(errs),1) 115 self.assertEqual(errs, [('local_roles', 'no list')]) 116 errs, inv_errs, conv_dict = self.processor.checkConversion( 117 dict(faculty_code='ABC', local_roles= 118 "[{'name':'bob','local_role':'waeup.local.DepartmentManager'},]" 119 )) 120 self.assertEqual(len(errs),1) 121 self.assertEqual(errs, [('local_roles', 'user_name or local_role missing')]) 122 errs, inv_errs, conv_dict = self.processor.checkConversion( 123 dict(faculty_code='ABC', local_roles= 124 "[{'user_name':'bob','localrole':'waeup.local.DepartmentManager'},]" 125 )) 126 self.assertEqual(len(errs),1) 127 self.assertEqual(errs, [('local_roles', 'user_name or local_role missing')]) 128 errs, inv_errs, conv_dict = self.processor.checkConversion( 129 dict(faculty_code='ABC', local_roles= 130 "[{'user_name':'bob','local_role':'waeup.local.Boss'},]" 131 )) 132 self.assertEqual(len(errs),1) 133 self.assertEqual(errs, [('local_roles', 'waeup.local.Boss not allowed')]) 134 errs, inv_errs, conv_dict = self.processor.checkConversion( 135 dict(faculty_code='ABC', local_roles= 136 "[{'user_name':'john','local_role':'waeup.local.DepartmentManager'},]" 137 )) 138 self.assertEqual(len(errs),1) 139 self.assertEqual(errs, [('local_roles', 'john does not exist')]) 140 errs, inv_errs, conv_dict = self.processor.checkConversion( 141 dict(faculty_code='ABC', local_roles= 142 "[{'user_name':'bob','local_role':'waeup.local.DepartmentManager'},]" 143 )) 144 self.assertEqual(len(errs),0) 60 145 return 61 146
Note: See TracChangeset for help on using the changeset viewer.