## $Id: tests.py 12911 2015-05-07 08:41:01Z henrik $ ## ## Copyright (C) 2015 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## import tempfile import os from hurry.workflow.interfaces import IWorkflowState from zope.component import getUtility from waeup.kofa.students.tests.test_browser import StudentsFullSetup from waeup.kofa.students.interfaces import IStudentsUtils from waeup.kwarapoly.testing import FunctionalLayer from waeup.kwarapoly.university.export import CustomDepartmentExporter class DepartmentExporterTest(StudentsFullSetup): layer = FunctionalLayer def test_export_all(self): self.workdir = tempfile.mkdtemp() self.outfile = os.path.join(self.workdir, 'myoutput.csv') utils = getUtility(IStudentsUtils) self.student.matric_number = None self.student['studycourse'].entry_session = 2015 IWorkflowState(self.student).setState('school fee paid') msg, mnumber = utils.setMatricNumber(self.student) self.assertEqual(msg, 'Matriculation number cannot be set.') self.assertEqual(mnumber, None) self.student['studycourse'].entry_mode = 'nd_ft' msg, mnumber = utils.setMatricNumber(self.student) exporter = CustomDepartmentExporter() exporter.export_all(self.app, self.outfile) result = open(self.outfile, 'rb').read() self.assertEqual( result, 'code,faculty_code,title,title_prefix,users_with_local_roles,' 'next_matric_dict\r\n' 'dep1,fac1,Unnamed Department,department,[],{2015: 2}\r\n' ) return