source: WAeUP_SRP/branches/uli/tests/test_tables.py @ 10281

Last change on this file since 10281 was 1561, checked in by uli, 18 years ago

Fixed broken accomodation initialization. Updated portal_accomodation tests.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1# (C) Copyright 2006 AixtraWare <http://aixtraware.de>
2# Author: Joachim Schmitz <js@aixtraware.de>
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License version 2 as published
6# by the Free Software Foundation.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16# 02111-1307, USA.
17#
18# $Id: test_tables.py 1561 2007-03-16 03:45:15Z uli $
19import unittest
20
21from waeuptest import WAeUP_SRPTest
22
23class TestTables(WAeUP_SRPTest):
24   
25    # Test that data does not go away on reinstall
26    def test_accomodation_install(self):
27        # Make sure the table got installed properly
28        patool = self.portal.portal_accommodation
29        self.failUnlessEqual(patool.meta_type, 'WAeUP Accommodation Tool')
30        schemalist = patool.schema()
31        schemalist.sort()
32        self.failUnlessEqual(schemalist, ['bed', 'bed_type', 'hall', 'student'])
33        indexeslist = patool.indexes()
34        indexeslist.sort()
35        self.failUnlessEqual(indexeslist, ['bed', 'bed_type', 'hall', 'student'])
36       
37    def test_accomodation_add_change_delete(self):
38        patool = self.portal.portal_accommodation
39       
40        # Add
41        uid = patool.addRecord(bed='bed', bed_type='fresh', hall='hall', student='student')
42        result = patool.searchResults({'bed':'bed'})
43        self.failUnlessEqual(len(result), 1)
44        self.failUnlessEqual(result[0].hall, 'hall')
45        self.failUnlessEqual(result[0].student, 'student')
46        self.failUnlessEqual(result[0].bed, 'bed')
47        self.failUnlessEqual(result[0].bed_type, 'fresh')
48       
49        # Change
50        patool.modifyRecord(bed=uid, student='newstudent')
51        result = patool.searchResults({'bed':'bed'})
52        self.failUnlessEqual(len(result), 1)
53        self.failUnlessEqual(result[0].student, 'newstudent')
54       
55        # Delete
56        patool.deleteRecord(uid)
57        result = patool.searchResults({'bed':'bed'})
58        self.failUnlessEqual(len(result), 0)
59   
60
61def test_suite():
62    return unittest.TestSuite((
63        unittest.makeSuite(TestTables),
64        ))
Note: See TracBrowser for help on using the repository browser.