# (C) Copyright 2006 AixtraWare # Author: Joachim Schmitz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # # $Id: test_tables.py 404 2006-08-22 21:45:50Z joachim $ import unittest from waeuptest import WAeUP_SRPTest class TestTables(WAeUP_SRPTest): # Test that data does not go away on reinstall def test_install(self): # Make sure the table got installed properly patool = self.portal.portal_accommodation self.failUnlessEqual(patool.meta_type, 'WAeUP Accommodation Tool') self.failUnlessEqual(patool.schema(), ['bed', 'student']) self.failUnlessEqual(patool.indexes(), ['bed', 'student']) def test_add_change_delete(self): patool = self.portal.portal_accommodation # Add uid = patool.addRecord(bed='bed', student='student') result = patool.searchResults({'bed':'bed'}) self.failUnlessEqual(len(result), 1) self.failUnlessEqual(result[0].student, 'student') # Change patool.modifyRecord(uid, student='newstudent') result = patool.searchResults({'bed':'bed'}) self.failUnlessEqual(len(result), 1) self.failUnlessEqual(result[0].student, 'newstudent') # Delete patool.deleteRecord(uid) result = patool.searchResults({'bed':'bed'}) self.failUnlessEqual(len(result), 0) def test_suite(): return unittest.TestSuite(( unittest.makeSuite(TestTables), ))