Changeset 9734 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 28 Nov 2012, 01:14:33 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9702 r9734 1 import grok 1 2 import datetime 2 3 from zope.component import queryUtility 4 from zope.event import notify 3 5 from zope.interface.verify import verifyObject, verifyClass 4 6 from waeup.kofa.interfaces import ICSVExporter … … 6 8 StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter, 7 9 CourseTicketExporter, PaymentsExporter, BedTicketsExporter, 8 StudentPaymentsOverviewExporter) 10 StudentPaymentsOverviewExporter, get_students, StudentsExportFilter) 11 from waeup.kofa.students.accommodation import BedTicket 12 from waeup.kofa.students.interfaces import ICSVStudentExporter 9 13 from waeup.kofa.students.payments import StudentOnlinePayment 10 from waeup.kofa.students. accommodation import BedTicket14 from waeup.kofa.students.student import Student 11 15 from waeup.kofa.students.studycourse import StudentStudyCourse 12 16 from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket … … 18 22 year_range_str = ','.join([str(i) for i in year_range]) 19 23 24 class ExportHelperTests(StudentImportExportSetup): 25 layer = FunctionalLayer 26 def setUp(self): 27 super(ExportHelperTests, self).setUp() 28 student = Student() 29 self.app['students'].addStudent(student) 30 student = self.setup_student(student) 31 notify(grok.ObjectModifiedEvent(student)) 32 self.student = self.app['students'][student.student_id] 33 return 34 35 def test_get_students_plain(self): 36 # without a filter we get all students 37 result = get_students(self.app) 38 self.assertEqual(len(list(result)), 1) 39 return 40 41 def test_get_students_by_session(self): 42 # we can filter out students of a certain session 43 my_filter1 = StudentsExportFilter(session=2012) 44 result = get_students(self.app, stud_filter=my_filter1) 45 self.assertEqual(len(list(result)), 1) 46 47 my_filter2 = StudentsExportFilter(session=1964) 48 result = get_students(self.app, stud_filter=my_filter2) 49 self.assertEqual(len(list(result)), 0) 50 return 51 52 def test_get_students_by_level(self): 53 # we can filter out students of a certain level 54 my_filter1 = StudentsExportFilter(level=200) 55 result = get_students(self.app, stud_filter=my_filter1) 56 self.assertEqual(len(list(result)), 1) 57 58 my_filter2 = StudentsExportFilter(level=300) 59 result = get_students(self.app, stud_filter=my_filter2) 60 self.assertEqual(len(list(result)), 0) 61 return 20 62 21 63 class StudentsExporterTest(StudentImportExportSetup): … … 31 73 # make sure we fullfill interface contracts 32 74 obj = StudentsExporter() 33 verifyObject(ICSV Exporter, obj)34 verifyClass(ICSV Exporter, StudentsExporter)75 verifyObject(ICSVStudentExporter, obj) 76 verifyClass(ICSVStudentExporter, StudentsExporter) 35 77 return 36 78
Note: See TracChangeset for help on using the changeset viewer.