source: WAeUP_SRP/branches/uli/tests/test_waeuptool.py @ 6645

Last change on this file since 6645 was 1604, checked in by uli, 18 years ago

Updated waeuptool tests

File size: 8.8 KB
Line 
1##
2## test_waeuptool.py
3## Login : <uli@gnufix.de>
4## Started on  Sun Mar 18 05:36:19 2007 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2007 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22import unittest
23
24from waeuptest import WAeUP_SRPTest
25
26class TestWAeUP_Tool(WAeUP_SRPTest):
27    """Tests for WAeUP tool.
28
29    XXX Currently almost all tests check only, whether a certain
30    method exists in waeuptool. Real unit tests have to be
31    implemented.
32    """
33   
34    def test_waeuptool_install(self):
35        """Check, whether a waeup_tool is available in site root.
36        """
37        self.assertTrue( hasattr(self.portal,  "waeup_tool" ),
38                         "WAeUP site got no waeup_tool")
39        wtool = self.portal.waeup_tool
40        return
41
42    def test_getLogfileLines(self):
43        """Check waeup_tool method getLogfileLines().
44        """
45        wtool = self.portal.waeup_tool
46        self.assertTrue( hasattr( wtool, "getLogfileLines" ),
47                         "waeup_tool got no method getLogfileLines")
48        result = wtool.getLogfileLines( "event.log", 23 )
49        self.failIfEqual( result, "" )
50        self.failUnlessEqual( len(result), 23)
51        result = wtool.getLogfileLines( "Z2.log", 23 )
52        self.failUnlessEqual( len(result), 23)
53        result = wtool.getLogfileLines( "Z2.log", -1 )
54        self.failUnlessEqual( len(result), 0)
55        result = wtool.getLogfileLines( "Z2.log" )
56        self.failUnlessEqual( len(result), 20)
57        result = wtool.getLogfileLines( "NotExistingFile" )
58        self.failUnlessEqual( len(result), 0)
59        result = wtool.getLogfileLines()
60        self.failUnlessEqual( len(result), 20)
61        return
62
63    def test_generateStudentId(self):
64        """Check waeup_tool method generateStudentId().
65        """
66        wtool = self.portal.waeup_tool
67        self.assertTrue( hasattr( wtool, "generateStudentId" ),
68                         "waeup_tool got no method generateStudentId()")
69        result = wtool.generateStudentId( 'A' ) # Deliver a leading char...
70        self.assertTrue( len(result) == 7,
71                         "Generated StudentId length != 7: %s"%result )
72        self.assertTrue( result[0] == "A",
73                         "Generated StudentId first char != 'A': %s"%result)
74        self.assertTrue( False not in [x in "0123456789" for x in result[1:]],
75                         "Generated StudentId contains non digits: %s"%result)
76
77        result = wtool.generateStudentId( '?' ) # Deliver no leading char...
78        self.assertTrue( len(result) == 7,
79                         "Generated StudentId length != 7: %s"%result )
80        self.assertTrue( result[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
81                         "Generated StudentId first char not alphabetical: %s"%result)
82        self.assertTrue( False not in [x in "0123456789" for x in result[1:]],
83                         "Generated StudentId contains non digits: %s"%result)
84
85        try:
86            result = wtool.generateStudentId( '' ) # Deliver empty char...
87        except TypeError:
88            self.fail( "waeuptool.generateStudentId accepts only chars and '?' as argument." )
89        self.assertTrue( len(result) == 7,
90                         "Generated StudentId length != 7: %s"%result )
91        self.assertTrue( result[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
92                         "Generated StudentId first char not alphabetical: %s"%result)
93        self.assertTrue( False not in [x in "0123456789" for x in result[1:]],
94                         "Generated StudentId contains non digits: %s"%result)
95
96        return
97
98    def test_generatePassword(self):
99        """Check waeup_tool method generatePassword().
100        """
101        wtool = self.portal.waeup_tool
102        self.assertTrue( hasattr( wtool, "generatePassword" ),
103                         "waeup_tool got no method generatePassword()")
104        return
105
106    def test_getCredential(self):
107        """Check waeup_tool method getCredential().
108        """
109        wtool = self.portal.waeup_tool
110        self.assertTrue( hasattr( wtool, "getCredential" ),
111                         "waeup_tool got no method getCredential()")
112        return
113
114    def test_checkPassword(self):
115        """Check waeup_tool method checkPassword()
116        """
117        wtool = self.portal.waeup_tool
118        self.assertTrue( hasattr( wtool, "checkPassword" ),
119                         "waeup_tool got no method checkPassword()")
120        return
121
122    def test_editPassword(self):
123        """Check waeup_tool method editPassword()
124        """
125        wtool = self.portal.waeup_tool
126        self.assertTrue( hasattr( wtool, "editPassword" ),
127                         "waeup_tool got no method editPassword()")
128        return
129
130    def test_doCommit(self):
131        """Check waeup_tool method doCommit()
132        """
133        wtool = self.portal.waeup_tool
134        self.assertTrue( hasattr( wtool, "doCommit" ),
135                         "waeup_tool got no method doCommit()")
136        return
137
138    def test_loadStudentFoto(self):
139        """Check waeup_tool method loadStudentFoto()
140        """
141        wtool = self.portal.waeup_tool
142        self.assertTrue( hasattr( wtool, "loadStudentFoto" ),
143                         "waeup_tool got no method loadStudentFoto()")
144        return
145
146    def test_loadStudentFoto(self):
147        """Check waeup_tool method loadStudentFoto()
148        """
149        wtool = self.portal.waeup_tool
150        self.assertTrue( hasattr( wtool, "loadStudentFoto" ),
151                         "waeup_tool got no method loadStudentFoto()")
152        return
153
154    def test_createOne(self):
155        """Check waeup_tool method createOne()
156        """
157        wtool = self.portal.waeup_tool
158        self.assertTrue( hasattr( wtool, "createOne" ),
159                         "waeup_tool got no method createOne()")
160        return
161
162    def test_createStudent(self):
163        """Check waeup_tool method createStudent()
164        """
165        wtool = self.portal.waeup_tool
166        self.assertTrue( hasattr( wtool, "createStudent" ),
167                         "waeup_tool got no method createStudent()")
168        return
169
170    def test_getCertificateBrain(self):
171        """Check waeup_tool method getCertificateBrain()
172        """
173        wtool = self.portal.waeup_tool
174        self.assertTrue( hasattr( wtool, "getCertificateBrain" ),
175                         "waeup_tool got no method getCertificateBrain()")
176        return
177
178    def test_findStudentByMatricelNo(self):
179        """Check waeup_tool method findStudentByMatricelNo()
180        """
181        wtool = self.portal.waeup_tool
182        self.assertTrue( hasattr( wtool, "findStudentByMatricelNo" ),
183                         "waeup_tool got no method findStudentByMatricelNo()")
184        return
185
186    def test_makeStudentMember(self):
187        """Check waeup_tool method makeStudentMember()
188        """
189        wtool = self.portal.waeup_tool
190        self.assertTrue( hasattr( wtool, "makeStudentMember" ),
191                         "waeup_tool got no method makeStudentMember()")
192        return
193
194    def test_makeStudentData(self):
195        """Check waeup_tool method makeStudentData()
196        """
197        wtool = self.portal.waeup_tool
198        self.assertTrue( hasattr( wtool, "makeStudentData" ),
199                         "waeup_tool got no method makeStudentData()")
200        return
201
202    def test_makeStudentLevel(self):
203        """Check waeup_tool method makeStudentLevel()
204        """
205        wtool = self.portal.waeup_tool
206        self.assertTrue( hasattr( wtool, "makeStudentLevel" ),
207                         "waeup_tool got no method makeStudentLevel()")
208        return
209
210    def test_getAccommodationInfo(self):
211        """Check waeup_tool method getAccommodationInfo()
212        """
213        wtool = self.portal.waeup_tool
214        self.assertTrue( hasattr( wtool, "getAccommodationInfo" ),
215                         "waeup_tool got no method getAccommodationInfo()")
216        return
217
218    def test_deleteAllCourses(self):
219        """Check waeup_tool method deleteAllCourses()
220        """
221        wtool = self.portal.waeup_tool
222        self.assertTrue( hasattr( wtool, "deleteAllCourses" ),
223                         "waeup_tool got no method deleteAllCourses()")
224        return
225
226
227   
228def test_suite():
229    return unittest.TestSuite((
230        unittest.makeSuite(TestWAeUP_Tool),
231        ))
232
Note: See TracBrowser for help on using the repository browser.