source: main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_browser.py @ 9022

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

Change title and msg of some workflow transitions.

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1## $Id: test_browser.py 9022 2012-07-19 07:11:32Z 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"""
19Test the student-related UI components.
20"""
21import shutil
22import tempfile
23import pytz
24from datetime import datetime, timedelta
25from StringIO import StringIO
26import os
27import grok
28from zope.event import notify
29from zope.component import createObject, queryUtility
30from zope.component.hooks import setSite, clearSite
31from zope.catalog.interfaces import ICatalog
32from zope.security.interfaces import Unauthorized
33from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
34
35from waeup.kofa.utils.browser import replaceStudentMessages
36from waeup.kofa.students.tests.test_browser import StudentsFullSetup
37
38class UtilsUITests(StudentsFullSetup):
39
40    layer = FunctionalLayer
41
42    def test_replace_student_messages(self):
43        self.assertTrue('Record created by system' in
44            self.student.history.messages[0])
45        replaceStudentMessages('system', 'me')
46        self.assertTrue('Record created by me' in
47            self.student.history.messages[0])
48
49    def test_modify_all_student_history(self):
50        self.assertTrue('Record created by system' in
51            self.student.history.messages[0])
52        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
53        self.browser.open('http://localhost/app/modify_student_history')
54        self.assertTrue(
55            'Syntax: /modify_student_history?old=[old string]&new=[new string]'
56            in self.browser.contents)
57        self.browser.open(
58            'http://localhost/app/modify_student_history?old=by system&new=by me')
59        self.assertTrue('Finished' in self.browser.contents)
60        self.assertTrue('Record created by me' in
61            self.student.history.messages[0])
62
63    def test_reindex(self):
64        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
65        self.browser.open('http://localhost/app/reindex')
66        self.assertTrue('No catalog name provided' in self.browser.contents)
67        self.browser.open('http://localhost/app/reindex?ctlg=xyz')
68        self.assertTrue('xyz_catalog does not exist' in self.browser.contents)
69        cat = queryUtility(ICatalog, name='students_catalog')
70        results = cat.searchResults(student_id=(None, None))
71        self.assertEqual(len(results),1)
72        cat.clear()
73        results = cat.searchResults(student_id=(None, None))
74        self.assertEqual(len(results),0)
75        self.browser.open('http://localhost/app/reindex?ctlg=students')
76        self.assertTrue('1 students re-indexed' in self.browser.contents)
77        results = cat.searchResults(student_id=(None, None))
78        self.assertEqual(len(results),1)
Note: See TracBrowser for help on using the repository browser.