1 | # Tests for student related reports |
---|
2 | from waeup.kofa.students.reports import get_students_by_session, StudentReport |
---|
3 | from waeup.kofa.students.tests.test_catalog import CatalogTestSetup |
---|
4 | from waeup.kofa.testing import FunctionalLayer |
---|
5 | |
---|
6 | class StudentReportTests(CatalogTestSetup): |
---|
7 | |
---|
8 | layer = FunctionalLayer |
---|
9 | |
---|
10 | states = ('created', 'admitted', 'clearance started', |
---|
11 | 'clearance requested', 'cleared', 'school fee paid', |
---|
12 | 'returning', 'courses registered', 'courses validated', 'Total') |
---|
13 | |
---|
14 | def test_get_students_by_session_simple(self): |
---|
15 | # we can get a table with one student |
---|
16 | result1 = get_students_by_session(2010) |
---|
17 | result2 = get_students_by_session(2009) |
---|
18 | self.assertEqual( |
---|
19 | result1, |
---|
20 | ((u'fac1', u'Total',), |
---|
21 | self.states, |
---|
22 | ((1, 0, 0, 0, 0, 0, 0, 0, 0, 1), |
---|
23 | (1, 0, 0, 0, 0, 0, 0, 0, 0, 1),))) |
---|
24 | self.assertEqual( |
---|
25 | result2, |
---|
26 | ((u'fac1', u'Total'), |
---|
27 | self.states, |
---|
28 | ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), |
---|
29 | (0, 0, 0, 0, 0, 0, 0, 0, 0, 0),))) |
---|
30 | return |
---|
31 | |
---|
32 | def test_get_students_by_session_multiple(self): |
---|
33 | # we can get a table with several students |
---|
34 | self.create_cert('fac2', 'dept2', 'CERT2') |
---|
35 | result1 = get_students_by_session(2010) |
---|
36 | result2 = get_students_by_session(2009) |
---|
37 | self.assertEqual( |
---|
38 | result1, |
---|
39 | ((u'fac1', u'fac2', u'Total'), |
---|
40 | self.states, |
---|
41 | ((1, 0, 0, 0, 0, 0, 0, 0, 0, 1), |
---|
42 | (0, 0, 0, 0, 0, 0, 0, 0, 0, 0), |
---|
43 | (1, 0, 0, 0, 0, 0, 0, 0, 0, 1),))) |
---|
44 | self.assertEqual( |
---|
45 | result2, |
---|
46 | ((u'fac1', u'fac2', u'Total'), |
---|
47 | self.states, |
---|
48 | ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), |
---|
49 | (0, 0, 0, 0, 0, 0, 0, 0, 0, 0), |
---|
50 | (0, 0, 0, 0, 0, 0, 0, 0, 0, 0),))) |
---|
51 | return |
---|
52 | |
---|
53 | def test_create_pdf(self): |
---|
54 | self.create_cert('FAC2', 'dept2', 'CERT2') |
---|
55 | report = StudentReport(2010) |
---|
56 | result = report.create_pdf() |
---|
57 | self.assertTrue(result.startswith('%PDF-')) |
---|
58 | return |
---|