Changeset 6985


Ignore:
Timestamp:
1 Nov 2011, 12:06:16 (13 years ago)
Author:
Henrik Bettermann
Message:

Add more tests for hostel management.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py

    r6973 r6985  
    145145        return
    146146
    147     def test_add_search_edit_delete_hostels(self):
     147    def test_add_search_edit_delete_manage_hostels(self):
    148148        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    149149        self.browser.open(self.container_path)
     
    157157        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    158158        self.assertTrue('Hostel created' in self.browser.contents)
    159         #import pdb; pdb.set_trace()
    160159        hall = self.app['hostels']['hall-1']
    161160        hall.blocks_for_female = ['A','B']
     
    165164        self.assertMatches(expected,self.browser.contents)
    166165        self.browser.open(self.container_path + '/hall-1/manage')
    167         self.browser.getControl(name="form.floors_per_block").value = '4'
     166        self.browser.getControl(name="form.rooms_per_floor").value = '1'
    168167        self.browser.getControl("Save").click()
    169168        self.assertTrue('Form has been saved' in self.browser.contents)
     169        # Since the testbrowser does not support Javascrip the
     170        # save action cleared the settings above and we have to set them
     171        # again
     172        self.assertTrue(len(hall.blocks_for_female) == 0)
     173        hall.blocks_for_female = ['A','B']
     174        hall.beds_for_fresh = ['A','B']
     175        hall.beds_for_all = ['D','E']
     176        self.browser.getControl("Update all beds").click()
     177        expected = '...0 empty beds removed, 8 beds added, 0 occupied beds modified...'
     178        self.assertMatches(expected,self.browser.contents)
     179        cat = queryUtility(ICatalog, name='beds_catalog')
     180        results = cat.searchResults(
     181            bed_type=('regular_female_all', 'regular_female_all'))
     182        #import pdb; pdb.set_trace()
     183        results = [x for x in results]
     184        assert len(results) == 4
     185        # Set bed reserved
     186        ctrl = self.browser.getControl(name='val_id')
     187        ctrl.getControl(value='hall-1_A_101_D').selected = True
     188        self.browser.getControl("Switch reservation", index=0).click()
     189        self.assertTrue('Successfully switched beds: hall-1_A_101_D'
     190            in self.browser.contents)
     191        assert self.app[
     192            'hostels'][
     193            'hall-1'][
     194            '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"  />'
     196        self.assertTrue(expected in self.browser.contents)
     197        # Release bed
     198        ctrl = self.browser.getControl(name='val_id')
     199        ctrl.getControl(value='hall-1_A_101_D').selected = True
     200        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)
     206        # Change hostel configuration
     207        hall.beds_for_all = ['D']
     208        self.browser.getControl("Update all beds").click()
     209        expected = '...8 empty beds removed, 6 beds added, 0 occupied beds modified...'
     210        self.assertMatches(expected,self.browser.contents)
     211        results = cat.searchResults(
     212            bed_type=('regular_female_all', 'regular_female_all'))
     213        results = [x for x in results]
     214        assert len(results) == 2
     215        # Remove entire hostel
    170216        self.browser.open(self.manage_container_path)
    171217        ctrl = self.browser.getControl(name='val_id')
     
    174220        self.browser.getControl("Remove selected", index=0).click()
    175221        self.assertTrue('Successfully removed' in self.browser.contents)
     222        # Catalog is empty
     223        results = cat.searchResults(
     224            bed_type=('regular_female_all', 'regular_female_all'))
     225        results = [x for x in results]
     226        assert len(results) == 0
Note: See TracChangeset for help on using the changeset viewer.