[363] | 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 $ |
---|
| 19 | import unittest |
---|
| 20 | |
---|
| 21 | from waeuptest import WAeUP_SRPTest |
---|
| 22 | |
---|
| 23 | class TestTables(WAeUP_SRPTest): |
---|
| 24 | |
---|
| 25 | # Test that data does not go away on reinstall |
---|
[1561] | 26 | def test_accomodation_install(self): |
---|
[363] | 27 | # Make sure the table got installed properly |
---|
[404] | 28 | patool = self.portal.portal_accommodation |
---|
| 29 | self.failUnlessEqual(patool.meta_type, 'WAeUP Accommodation Tool') |
---|
[1561] | 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']) |
---|
[363] | 36 | |
---|
[1561] | 37 | def test_accomodation_add_change_delete(self): |
---|
[404] | 38 | patool = self.portal.portal_accommodation |
---|
[363] | 39 | |
---|
| 40 | # Add |
---|
[1561] | 41 | uid = patool.addRecord(bed='bed', bed_type='fresh', hall='hall', student='student') |
---|
[363] | 42 | result = patool.searchResults({'bed':'bed'}) |
---|
| 43 | self.failUnlessEqual(len(result), 1) |
---|
[1561] | 44 | self.failUnlessEqual(result[0].hall, 'hall') |
---|
[363] | 45 | self.failUnlessEqual(result[0].student, 'student') |
---|
[1561] | 46 | self.failUnlessEqual(result[0].bed, 'bed') |
---|
| 47 | self.failUnlessEqual(result[0].bed_type, 'fresh') |
---|
[363] | 48 | |
---|
| 49 | # Change |
---|
[1561] | 50 | patool.modifyRecord(bed=uid, student='newstudent') |
---|
[363] | 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 | |
---|
| 61 | def test_suite(): |
---|
| 62 | return unittest.TestSuite(( |
---|
| 63 | unittest.makeSuite(TestTables), |
---|
| 64 | )) |
---|