Changeset 9448 for main/waeup.kofa/trunk/src/waeup/kofa/hostels
- Timestamp:
- 28 Oct 2012, 20:12:11 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/hostels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py
r9414 r9448 127 127 bed.bed_type = bt 128 128 modified_counter += 1 129 modified_beds += '%s ' % uid 129 modified_beds += '%s, ' % uid 130 notify(grok.ObjectModifiedEvent(bed)) 130 131 else: 131 132 bed = Bed() … … 243 244 message = _(u'reserved') 244 245 self.bed_type = bt 246 notify(grok.ObjectModifiedEvent(self)) 245 247 return message 246 248 -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r9423 r9448 253 253 results = cat.searchResults( 254 254 bed_type=('regular_female_all', 'regular_female_all')) 255 results = [x for x in results] 256 assert len(results) == 4 255 results = [(x.bed_id, x.bed_type) for x in results] 256 self.assertEqual(results, 257 [(u'hall-1_A_101_D', u'regular_female_all'), 258 (u'hall-1_A_101_E', u'regular_female_all'), 259 (u'hall-1_B_101_D', u'regular_female_all'), 260 (u'hall-1_B_101_E', u'regular_female_all')]) 261 257 262 # Reserve bed 258 263 self.browser.getControl("Switch reservation", index=0).click() … … 266 271 self.assertTrue('Successfully switched beds: hall-1_A_101_A (reserved)' 267 272 in self.browser.contents) 268 assertself.app['hostels']['hall-1'][269 'hall-1_A_101_D'].bed_type == 'regular_female_reserved'273 self.assertEqual(self.app['hostels']['hall-1'][ 274 'hall-1_A_101_D'].bed_type, 'regular_female_reserved') 270 275 self.assertTrue('<div>A_101_A</div>' in self.browser.contents) 271 272 # Change hostel configuration 276 # The catalog has been updated 277 results = cat.searchResults( 278 bed_type=('regular_female_all', 'regular_female_all')) 279 results = [(x.bed_id, x.bed_type) for x in results] 280 self.assertEqual(results, 281 [(u'hall-1_A_101_E', u'regular_female_all'), 282 (u'hall-1_B_101_D', u'regular_female_all'), 283 (u'hall-1_B_101_E', u'regular_female_all')]) 284 results = cat.searchResults( 285 bed_type=('regular_female_reserved', 'regular_female_reserved')) 286 results = [(x.bed_id, x.bed_type) for x in results] 287 self.assertEqual(results, 288 [(u'hall-1_A_101_A', u'regular_female_reserved'), 289 (u'hall-1_A_101_B', u'regular_female_reserved'), 290 (u'hall-1_A_101_C', u'regular_female_reserved'), 291 (u'hall-1_A_101_D', u'regular_female_reserved')]) 292 293 # Change hostel configuration with one bed booked 294 hall['hall-1_A_101_E'].owner = u'anyid' 295 notify(grok.ObjectModifiedEvent(hall['hall-1_A_101_E'])) 296 hall.beds_for_fresh = ['A', 'E'] 273 297 hall.beds_for_all = ['D'] 274 298 self.browser.getControl("Update all beds").click() 275 expected = '... 10 empty beds removed, 8 beds added, 0occupied beds modified...'299 expected = '...9 empty beds removed, 9 beds added, 1 occupied beds modified...' 276 300 self.assertMatches(expected,self.browser.contents) 301 # Updating beds (including booked beds!) does update catalog 277 302 results = cat.searchResults( 278 303 bed_type=('regular_female_all', 'regular_female_all')) 279 results = [x for x in results] 280 assert len(results) == 1 304 results = [(x.bed_id, x.bed_type) for x in results] 305 self.assertEqual(results, 306 [(u'hall-1_B_101_D', u'regular_female_all'),]) 281 307 # Unreserve bed 282 308 ctrl = self.browser.getControl(name='val_id') … … 348 374 old_owner = self.app['hostels']['hall-1']['hall-1_A_101_A'].owner 349 375 self.browser.getControl("Update all beds").click() 350 # 7 beds have been removed and re-added, 1 bed remains untouched 351 expected = '...7 empty beds removed, 7 beds added, 0 occupied beds modified...' 376 # 8 beds have been removed and re-added, 2 beds remains untouched 377 # because they are occupied 378 expected = '...8 empty beds removed, 8 beds added, 0 occupied beds modified...' 352 379 self.assertMatches(expected,self.browser.contents) 353 380 new_number = self.app['hostels']['hall-1']['hall-1_A_101_A'].bed_number … … 360 387 hall.blocks_for_male = ['A'] 361 388 self.browser.getControl("Update all beds").click() 362 expected = '... 7 empty beds removed, 7beds added, ' + \363 ' 1 occupied beds modified (hall-1_A_101_A)...'389 expected = '...8 empty beds removed, 8 beds added, ' + \ 390 '2 occupied beds modified (hall-1_A_101_A, hall-1_A_101_E, )...' 364 391 self.assertMatches(expected,self.browser.contents) 365 392 new_number = self.app['hostels']['hall-1']['hall-1_A_101_A'].bed_number … … 368 395 # The number of occupied beds are displayed on container page. 369 396 self.browser.open(self.container_path) 370 self.assertTrue(' 1 of 8' in self.browser.contents)397 self.assertTrue('2 of 10' in self.browser.contents) 371 398 # Remove entire hostel 372 399 self.browser.open(self.manage_container_path)
Note: See TracChangeset for help on using the changeset viewer.