Changeset 9763 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 3 Dec 2012, 16:30:10 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9761 r9763 42 42 def test_get_students_by_session(self): 43 43 # we can filter out students of a certain session 44 my_filter1 = StudentsExportFilter( session=2012)44 my_filter1 = StudentsExportFilter(current_session=2012) 45 45 result = get_students(self.app, stud_filter=my_filter1) 46 46 self.assertEqual(len(list(result)), 1) 47 47 48 my_filter2 = StudentsExportFilter( session=1964)48 my_filter2 = StudentsExportFilter(current_session=1964) 49 49 result = get_students(self.app, stud_filter=my_filter2) 50 50 self.assertEqual(len(list(result)), 0) … … 53 53 def test_get_students_by_level(self): 54 54 # we can filter out students of a certain level 55 my_filter1 = StudentsExportFilter( level=200)55 my_filter1 = StudentsExportFilter(current_level=200) 56 56 result = get_students(self.app, stud_filter=my_filter1) 57 57 self.assertEqual(len(list(result)), 1) 58 58 59 my_filter2 = StudentsExportFilter( level=300)59 my_filter2 = StudentsExportFilter(current_level=300) 60 60 result = get_students(self.app, stud_filter=my_filter2) 61 61 self.assertEqual(len(list(result)), 0) 62 62 return 63 63 64 def test_get_students_by_deptcode(self): 65 # we can filter out students of a certain dept. 66 my_filter1 = StudentsExportFilter(depcode='NA') 67 result = get_students(self.app, stud_filter=my_filter1) 68 self.assertEqual(len(list(result)), 1) 69 70 my_filter2 = StudentsExportFilter(depcode='NOTEXISTING') 71 result = get_students(self.app, stud_filter=my_filter2) 72 self.assertEqual(len(list(result)), 0) 73 return 74 75 def test_get_students_by_faccode(self): 76 # we can filter out students of a certain faculty. 77 my_filter1 = StudentsExportFilter(faccode='NA') 78 result = get_students(self.app, stud_filter=my_filter1) 79 self.assertEqual(len(list(result)), 1) 80 81 my_filter2 = StudentsExportFilter(faccode='NOTEXISTING') 82 result = get_students(self.app, stud_filter=my_filter2) 83 self.assertEqual(len(list(result)), 0) 84 return 85 86 64 87 class StudentsExporterTest(StudentImportExportSetup): 65 88 66 89 layer = FunctionalLayer 90 91 std_csv_entry = ( 92 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 93 'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n",,' 94 '+234-123-12345#,123,f,A111111,0,,,created' 95 ) 67 96 68 97 def setUp(self): … … 144 173 in result 145 174 ) 175 return 176 177 def test_export_filtered(self): 178 # we can export a filtered set of students (filtered by session/level) 179 self.setup_student(self.student) 180 self.app['students'].addStudent(self.student) 181 notify(grok.ObjectModifiedEvent(self.student)) 182 exporter = StudentsExporter() 183 184 exporter.export_filtered(self.app, None, None, filepath=self.outfile) 185 result1 = open(self.outfile, 'rb').read() 186 exporter.export_filtered(self.app, 2012, None, filepath=self.outfile) 187 result2 = open(self.outfile, 'rb').read() 188 exporter.export_filtered(self.app, None, 200, filepath=self.outfile) 189 result3 = open(self.outfile, 'rb').read() 190 exporter.export_filtered(self.app, 2011, None, filepath=self.outfile) 191 result4 = open(self.outfile, 'rb').read() 192 exporter.export_filtered(self.app, None, 100, filepath=self.outfile) 193 result5 = open(self.outfile, 'rb').read() 194 self.assertTrue(self.std_csv_entry in result1) 195 self.assertTrue(self.std_csv_entry in result2) 196 self.assertTrue(self.std_csv_entry in result3) 197 self.assertTrue(self.std_csv_entry not in result4) 198 self.assertTrue(self.std_csv_entry not in result5) 199 return 200 201 def test_export_filtered_by_dept(self): 202 # we can export a set of students filtered by department 203 self.setup_student(self.student) 204 self.app['students'].addStudent(self.student) 205 notify(grok.ObjectModifiedEvent(self.student)) 206 exporter = StudentsExporter() 207 208 exporter.export_filtered(self.app, 2012, 200, depcode='NA', 209 filepath=self.outfile) 210 result1 = open(self.outfile, 'rb').read() 211 exporter.export_filtered(self.app, 2012, 200, depcode='NODEPT', 212 filepath=self.outfile) 213 result2 = open(self.outfile, 'rb').read() 214 self.assertTrue(self.std_csv_entry in result1) 215 self.assertTrue(self.std_csv_entry not in result2) 216 return 217 218 def test_export_filtered_by_faculty(self): 219 # we can export a set of students filtered by faculty 220 self.setup_student(self.student) 221 self.app['students'].addStudent(self.student) 222 notify(grok.ObjectModifiedEvent(self.student)) 223 exporter = StudentsExporter() 224 225 exporter.export_filtered( 226 self.app, 2012, 200, faccode='NA', filepath=self.outfile) 227 result1 = open(self.outfile, 'rb').read() 228 exporter.export_filtered(self.app, 2012, 200, faccode='NOFAC', 229 filepath=self.outfile) 230 result2 = open(self.outfile, 'rb').read() 231 self.assertTrue(self.std_csv_entry in result1) 232 self.assertTrue(self.std_csv_entry not in result2) 146 233 return 147 234
Note: See TracChangeset for help on using the changeset viewer.