Changeset 6988 for main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py
- Timestamp:
- 2 Nov 2011, 11:23:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py
r6985 r6988 15 15 ## 16 16 """ 17 Tests for hostels . and their UI components17 Tests for hostels and their UI components. 18 18 """ 19 19 import shutil … … 157 157 self.assertEqual(self.browser.headers['Status'], '200 Ok') 158 158 self.assertTrue('Hostel created' in self.browser.contents) 159 self.browser.open(self.container_path + '/addhostel') 160 self.browser.getControl("Create hostel").click() 161 self.assertTrue('The hostel already exists' in self.browser.contents) 159 162 hall = self.app['hostels']['hall-1'] 160 163 hall.blocks_for_female = ['A','B'] … … 172 175 self.assertTrue(len(hall.blocks_for_female) == 0) 173 176 hall.blocks_for_female = ['A','B'] 174 hall.beds_for_fresh = ['A','B'] 177 hall.beds_for_fresh = ['A'] 178 hall.beds_for_returning = ['B'] 179 hall.beds_for_final = ['C'] 175 180 hall.beds_for_all = ['D','E'] 176 181 self.browser.getControl("Update all beds").click() 177 expected = '...0 empty beds removed, 8 beds added, 0 occupied beds modified...'182 expected = '...0 empty beds removed, 10 beds added, 0 occupied beds modified ()...' 178 183 self.assertMatches(expected,self.browser.contents) 179 184 cat = queryUtility(ICatalog, name='beds_catalog') 180 185 results = cat.searchResults( 181 186 bed_type=('regular_female_all', 'regular_female_all')) 182 #import pdb; pdb.set_trace()183 187 results = [x for x in results] 184 188 assert len(results) == 4 185 # Set bed reserved 186 ctrl = self.browser.getControl(name='val_id') 189 # Reserve bed 190 self.browser.getControl("Switch reservation", index=0).click() 191 self.assertTrue('No item selected' in self.browser.contents) 192 ctrl = self.browser.getControl(name='val_id') 193 ctrl.getControl(value='hall-1_A_101_A').selected = True 194 ctrl.getControl(value='hall-1_A_101_B').selected = True 195 ctrl.getControl(value='hall-1_A_101_C').selected = True 187 196 ctrl.getControl(value='hall-1_A_101_D').selected = True 188 197 self.browser.getControl("Switch reservation", index=0).click() 189 self.assertTrue('Successfully switched beds: hall-1_A_101_ D'198 self.assertTrue('Successfully switched beds: hall-1_A_101_A (reserved)' 190 199 in self.browser.contents) 191 assert self.app[ 192 'hostels'][ 193 'hall-1'][ 200 assert self.app['hostels']['hall-1'][ 194 201 'hall-1_A_101_D'].bed_type == 'regular_female_reserved' 195 expected = 'name="form.beds_reserved.0." size="20" type="text" value="A_101_ D" />'202 expected = 'name="form.beds_reserved.0." size="20" type="text" value="A_101_A" />' 196 203 self.assertTrue(expected in self.browser.contents) 197 # Release bed 204 # Provoke exception 205 self.app['hostels']['hall-1']['hall-1_A_101_D'].bed_type = u'nonsense' 198 206 ctrl = self.browser.getControl(name='val_id') 199 207 ctrl.getControl(value='hall-1_A_101_D').selected = True 200 208 self.browser.getControl("Switch reservation", index=0).click() 201 assert self.app[ 202 'hostels'][ 203 'hall-1'][ 204 'hall-1_A_101_D'].bed_type == 'regular_female_all' 205 self.assertFalse(expected in self.browser.contents) 209 self.assertMatches( 210 '...need more than 1 value to unpack...', self.browser.contents) 211 self.app['hostels']['hall-1'][ 212 'hall-1_A_101_D'].bed_type = u'regular_female_reserved' 206 213 # Change hostel configuration 207 214 hall.beds_for_all = ['D'] 208 215 self.browser.getControl("Update all beds").click() 209 expected = '... 8 empty beds removed, 6beds added, 0 occupied beds modified...'216 expected = '...10 empty beds removed, 8 beds added, 0 occupied beds modified...' 210 217 self.assertMatches(expected,self.browser.contents) 211 218 results = cat.searchResults( 212 219 bed_type=('regular_female_all', 'regular_female_all')) 213 220 results = [x for x in results] 214 assert len(results) == 2 221 assert len(results) == 1 222 # Unreserve bed 223 ctrl = self.browser.getControl(name='val_id') 224 ctrl.getControl(value='hall-1_A_101_A').selected = True 225 ctrl.getControl(value='hall-1_A_101_B').selected = True 226 ctrl.getControl(value='hall-1_A_101_C').selected = True 227 ctrl.getControl(value='hall-1_A_101_D').selected = True 228 self.browser.getControl("Switch reservation", index=0).click() 229 assert self.app['hostels']['hall-1'][ 230 'hall-1_A_101_D'].bed_type == 'regular_female_all' 231 self.assertFalse(expected in self.browser.contents) 215 232 # Remove entire hostel 216 233 self.browser.open(self.manage_container_path)
Note: See TracChangeset for help on using the changeset viewer.