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