source: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_move.py @ 12444

Last change on this file since 12444 was 10634, checked in by Henrik Bettermann, 11 years ago

Disable score editing on department manage page.

Add tests.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1## $Id: test_move.py 10634 2013-09-21 08:27:47Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""
19Tests for moving objects in faculties.
20"""
21import os
22from zope.catalog.interfaces import ICatalog
23from zope.component import queryUtility
24from waeup.kofa.university.department import Department
25from waeup.kofa.students.tests.test_browser import StudentsFullSetup
26
27class MoveObjectsInFaculties(StudentsFullSetup):
28
29    def test_move_certificate(self):
30        self.assertEqual(
31            self.app['faculties']['fac1']['dep1'].certificates['CERT1'],
32            self.certificate)
33        self.app['faculties']['fac1']['dep2'] = Department(code=u'dep2')
34        self.certificate.moveCertificate('fac1', 'dep2')
35        self.assertEqual(
36            self.app['faculties']['fac1']['dep2'].certificates['CERT1'],
37            self.certificate)
38        self.assertEqual(
39            [key for key in self.app['faculties']['fac1'][
40                'dep2'].certificates['CERT1'].keys()],
41            [u'COURSE1_100'])
42        self.assertEqual(
43            self.student['studycourse'].certificate,
44            self.certificate)
45
46        # We can still find the certificate in the catalog
47        cat = queryUtility(ICatalog, name='certificates_catalog')
48        results = cat.searchResults(code=('CERT1','CERT1'))
49        results = [x for x in results] # Turn results generator into list
50        assert len(results) == 1
51        assert results[0] is self.certificate
52
53        # We can find the student studying in the new department
54        cat = queryUtility(ICatalog, name='students_catalog')
55        results = cat.searchResults(depcode=('dep2','dep2'))
56        results = [x for x in results] # Turn results generator into list
57        assert len(results) == 1
58        assert results[0] is self.app['students'][self.student_id]
59        logfile = os.path.join(
60            self.app['datacenter'].storage, 'logs', 'students.log')
61        logcontent = open(logfile).read()
62        self.assertTrue('INFO - system - K1000000 - Certificate moved'
63            in logcontent)
64
Note: See TracBrowser for help on using the repository browser.