Ignore:
Timestamp:
6 Nov 2011, 08:54:08 (13 years ago)
Author:
Henrik Bettermann
Message:

Add test. The last test fails because the event handler is still missing.

File:
1 edited

Legend:

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

    r6946 r7005  
    3939from waeup.sirp.university.department import Department
    4040from waeup.sirp.interfaces import IUserAccount
     41from waeup.sirp.hostels.hostel import Hostel, Bed, NOT_OCCUPIED
    4142
    4243PH_LEN = 2059  # Length of placeholder file
     
    8788        student.reg_number = u'123'
    8889        student.matric_number = u'234'
     90        student.sex = u'm'
    8991        self.app['students'].addStudent(student)
    9092        self.student_id = student.student_id
     
    105107        self.edit_clearance_student_path = self.student_path + '/edit_clearance'
    106108        self.edit_personal_student_path = self.student_path + '/edit_personal'
    107 
    108109        self.studycourse_student_path = self.student_path + '/studycourse'
    109110        self.payments_student_path = self.student_path + '/payments'
    110         self.accommodation_student_path = self.student_path + '/accommodation'
     111        self.acco_student_path = self.student_path + '/accommodation'
    111112        self.history_student_path = self.student_path + '/history'
    112113
     
    151152            self.course, level=100)
    152153
     154        # Configure university
     155        self.app['configuration'].accommodation_states = ['admitted']
     156        self.app['configuration'].accommodation_session = 2004
     157        configuration = SessionConfiguration()
     158        configuration.academic_session = 2004
     159        configuration.fee_1 = 20000
     160        configuration.boocking_fee = 500
     161        self.app['configuration'].addSessionConfiguration(configuration)
     162
     163        # Create a hostel with bed
     164        hostel = Hostel()
     165        hostel.hostel_id = u'hall-1'
     166        hostel.hostel_name = u'Hall 1'
     167        self.app['hostels'].addHostel(hostel)
     168        bed = Bed()
     169        bed.bed_id = u'hall-1_A_101_A'
     170        bed.bed_number = 1
     171        bed.owner = NOT_OCCUPIED
     172        bed.bed_type = u'regular_male_fr'
     173        self.app['hostels'][hostel.hostel_id].addBed(bed)
     174
    153175        # Set study course attributes of test student
    154176        self.student['studycourse'].certificate = self.certificate
    155177        self.student['studycourse'].current_session = 2004
     178        self.student['studycourse'].entry_session = 2004
    156179        self.student['studycourse'].current_verdict = 'A'
    157180        self.student['studycourse'].current_level = 100
     
    308331        self.browser.getLink("Accommodation").click()
    309332        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    310         self.assertEqual(self.browser.url, self.accommodation_student_path)
     333        self.assertEqual(self.browser.url, self.acco_student_path)
    311334        self.browser.open(self.student_path)
    312335        self.browser.getLink("History").click()
     
    653676
    654677    def test_manage_payments(self):
    655         # Set up SessionConfiguration object
    656         configuration = SessionConfiguration()
    657         configuration.academic_session = 2004
    658         configuration.fee_1 = 20000
    659         self.app['configuration'].addSessionConfiguration(configuration)
    660 
    661678        # Managers can add online school fee payment tickets
    662679        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    726743
    727744
    728 
    729745    def test_student_payments(self):
    730746        # Set up SessionConfiguration object
    731         configuration = SessionConfiguration()
    732         configuration.academic_session = 2004
    733         configuration.fee_1 = 20000
    734         self.app['configuration'].addSessionConfiguration(configuration)
    735747        self.browser.open(self.login_path)
    736748        self.browser.getControl(name="form.login").value = self.student_id
     
    822834                           self.browser.contents)
    823835        self.assertTrue(self.student.state,'school fee paid')
     836
     837    def test_manage_accommodation(self):
     838        # Managers can add online booking fee payment tickets and open the
     839        # callback view (see test_manage_payments)
     840        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     841        self.browser.open(self.payments_student_path)
     842        self.browser.getControl("Add online payment ticket").click()
     843        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
     844        self.browser.getControl("Create ticket").click()
     845        ctrl = self.browser.getControl(name='val_id')
     846        value = ctrl.options[0]
     847        self.browser.getLink(value).click()
     848        self.browser.open(self.browser.url + '/callback')
     849        # The new HOS-0 pin has been created
     850        self.assertEqual(len(self.app['accesscodes']['HOS-0']),1)
     851        pin = self.app['accesscodes']['HOS-0'].keys()[0]
     852        ac = self.app['accesscodes']['HOS-0'][pin]
     853        ac.owner = self.student_id
     854        parts = pin.split('-')[1:]
     855        sfeseries, sfenumber = parts
     856        # Managers can use HOS code and book a bed space with it
     857        self.browser.open(self.acco_student_path)
     858        self.browser.getControl("Add bed ticket").click()
     859        self.assertMatches('...Wrong state...',
     860                           self.browser.contents)
     861        IWorkflowInfo(self.student).fireTransition('admit')
     862        self.browser.getControl("Add bed ticket").click()
     863        self.assertMatches('...Activation Code:...',
     864                           self.browser.contents)
     865        self.browser.getControl(name="ac_series").value = sfeseries
     866        self.browser.getControl(name="ac_number").value = sfenumber
     867        self.browser.getControl("Create bed ticket").click()
     868        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
     869                           self.browser.contents)
     870        # Bed has been allocated
     871        bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
     872        self.assertTrue(bed.owner,self.student_id)
     873        # BedTicketAddPage is now blocked
     874        self.browser.getControl("Add bed ticket").click()
     875        self.assertMatches('...Ticket for 2004 already created...',
     876            self.browser.contents)
     877        # The bed ticket displays the data correctly
     878        self.browser.open(self.acco_student_path + '/2004')
     879        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
     880                           self.browser.contents)
     881        self.assertMatches('...2004/2005...', self.browser.contents)
     882        self.assertMatches('...regular_male_fr...', self.browser.contents)
     883        self.assertMatches('...%s...' % pin, self.browser.contents)
     884        # Managers cab delete bed tickets
     885        self.browser.open(self.acco_student_path)
     886        ctrl = self.browser.getControl(name='val_id')
     887        value = ctrl.options[0]
     888        ctrl.getControl(value=value).selected = True
     889        self.browser.getControl("Remove selected", index=0).click()
     890        self.assertTrue('Successfully removed' in self.browser.contents)
     891        # Due to an event handler also the bed has been released properly
     892        bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
     893        self.assertTrue(bed.owner == NOT_OCCUPIED)
     894
     895    def test_student_accommodation(self):
     896        pass
Note: See TracChangeset for help on using the changeset viewer.