source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py @ 9046

Last change on this file since 9046 was 9046, checked in by Henrik Bettermann, 12 years ago

Fix tests.

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1import datetime
2from zope.component import queryUtility
3from zope.interface.verify import verifyObject, verifyClass
4from waeup.kofa.interfaces import ICSVExporter
5from waeup.kofa.schoolgrades import ResultEntry
6from waeup.kofa.students.tests.test_batching import StudentImportExportSetup
7
8from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
9from kofacustom.nigeria.students.export import NigeriaStudentsExporter
10from kofacustom.nigeria.testing import FunctionalLayer
11
12
13class NigeriaStudentsExporterTest(StudentImportExportSetup):
14
15    layer = FunctionalLayer
16
17    def setUp(self):
18        super(NigeriaStudentsExporterTest, self).setUp()
19        self.setup_for_export()
20        result_entry = ResultEntry(
21            NigeriaKofaUtils.EXAM_SUBJECTS_DICT.keys()[0],
22            NigeriaKofaUtils.EXAM_GRADES[0][0]
23            )
24        self.student.alr_results = [
25            result_entry]
26        self.student.fst_sit_results = [
27            result_entry]
28        self.student.scd_sit_results = [
29            result_entry]
30        return
31
32    def test_ifaces(self):
33        # make sure we fullfill interface contracts
34        obj = NigeriaStudentsExporter()
35        verifyObject(ICSVExporter, obj)
36        verifyClass(ICSVExporter, NigeriaStudentsExporter)
37        return
38
39
40    def test_export_all(self):
41        # we can really export students
42        # set values we can expect in export file
43        self.setup_student(self.student)
44        exporter = NigeriaStudentsExporter()
45        exporter.export_all(self.app, self.outfile)
46        result = open(self.outfile, 'rb').read()
47        self.assertTrue(
48            'adm_code,alr_date,alr_fname,alr_no,alr_results,clearance_locked,'
49            'clr_code,date_of_birth,def_adm,disabled,email,emp2_end,'
50            'emp2_position,emp2_reason,emp2_start,emp_end,emp_position,'
51            'emp_reason,emp_start,employer,employer2,firstname,former_matric,'
52            'fst_sit_date,fst_sit_fname,fst_sit_no,fst_sit_results,'
53            'fst_sit_type,hq2_degree,hq2_disc,hq2_matric_no,hq2_school,'
54            'hq2_session,hq2_type,hq_degree,hq_disc,hq_matric_no,hq_school,'
55            'hq_session,hq_type,is_staff,lastname,lga,marit_stat,'
56            'matric_number,middlename,nationality,next_kin_address,'
57            'next_kin_name,next_kin_relation,nysc_lga,nysc_location,'
58            'nysc_year,perm_address,phone,reg_number,religion,scd_sit_date,'
59            'scd_sit_fname,scd_sit_no,scd_sit_results,scd_sit_type,sex,'
60            'student_id,suspended,password,state,history,certcode\r\n'
61
62            'my adm code,,,,"[(\'visual_art\', \'A1\')]",0,my clr code,'
63            '1981-02-04#,,,anna@sample.com,,,,,,,,,,,Anna,,,,,'
64            '"[(\'visual_art\', \'A1\')]",,,,,,,,,,,,,,,Tester,,,234,M.,NG'
65            ',,,,,,,"Studentroad 21\nLagos 123456\n",+234-123-12345#,123'
66            ',,,,,"[(\'visual_art\', \'A1\')]",,f,A111111,0,,created,'
67            in result
68            )
69        return
70
71
Note: See TracBrowser for help on using the repository browser.