Ignore:
Timestamp:
28 Nov 2012, 01:14:33 (12 years ago)
Author:
uli
Message:

Try to make clearer where we head to regarding filtered exports.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r9702 r9734  
     1import grok
    12import datetime
    23from zope.component import queryUtility
     4from zope.event import notify
    35from zope.interface.verify import verifyObject, verifyClass
    46from waeup.kofa.interfaces import ICSVExporter
     
    68    StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter,
    79    CourseTicketExporter, PaymentsExporter, BedTicketsExporter,
    8     StudentPaymentsOverviewExporter)
     10    StudentPaymentsOverviewExporter, get_students, StudentsExportFilter)
     11from waeup.kofa.students.accommodation import BedTicket
     12from waeup.kofa.students.interfaces import ICSVStudentExporter
    913from waeup.kofa.students.payments import StudentOnlinePayment
    10 from waeup.kofa.students.accommodation import BedTicket
     14from waeup.kofa.students.student import Student
    1115from waeup.kofa.students.studycourse import StudentStudyCourse
    1216from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket
     
    1822year_range_str = ','.join([str(i) for i in year_range])
    1923
     24class 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
    2062
    2163class StudentsExporterTest(StudentImportExportSetup):
     
    3173        # make sure we fullfill interface contracts
    3274        obj = StudentsExporter()
    33         verifyObject(ICSVExporter, obj)
    34         verifyClass(ICSVExporter, StudentsExporter)
     75        verifyObject(ICSVStudentExporter, obj)
     76        verifyClass(ICSVStudentExporter, StudentsExporter)
    3577        return
    3678
Note: See TracChangeset for help on using the changeset viewer.