Changeset 6767 for main


Ignore:
Timestamp:
14 Sep 2011, 10:46:18 (13 years ago)
Author:
Henrik Bettermann
Message:

Add more tests.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
3 edited

Legend:

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

    r6762 r6767  
    713713        IWorkflowInfo(self.context).fireTransition('start_clearance')
    714714        self.flash('Clearance process is started.')
    715         self.redirect(self.url(self.context))
    716         return
     715        self.redirect(self.url(self.context,'cedit'))
     716        return
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r6764 r6767  
    3434    """
    3535    grok.implements(IStudent, IStudentNavigation,
    36         IStudentPersonalEdit)
     36        IStudentPersonalEdit, IStudentClearanceEdit)
    3737    grok.provides(IStudent)
    3838
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6766 r6767  
    3030from zope.security.interfaces import Unauthorized
    3131from zope.testbrowser.testing import Browser
     32from hurry.workflow.interfaces import IWorkflowInfo
    3233from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
    3334from waeup.sirp.app import University
     
    9495        self.history_student_path = self.student_path + '/history'
    9596
    96         # Create 5 access codes with prefix'PWD' and cost 9.99 each
     97        # Create 5 access codes with prefix'PWD'
    9798        pin_container = self.app['accesscodes']
    9899        pin_container.createBatch(
    99100            datetime.now(), 'some_userid', 'PWD', 9.99, 5)
    100101        pins = pin_container[pin_container.keys()[0]].values()
    101         self.pins = [x.representation for x in pins]
    102         self.existing_pin = self.pins[0]
    103         parts = self.existing_pin.split('-')[1:]
    104         self.existing_series, self.existing_number = parts
     102        self.pwdpins = [x.representation for x in pins]
     103        self.existing_pwdpin = self.pwdpins[0]
     104        parts = self.existing_pwdpin.split('-')[1:]
     105        self.existing_pwdseries, self.existing_pwdnumber = parts
     106        # Create 5 access codes with prefix 'CLR'
     107        pin_container.createBatch(
     108            datetime.now(), 'some_userid', 'CLR', 9.99, 5)
     109        pins = pin_container[pin_container.keys()[0]].values()
     110        self.clrpins = [x.representation for x in pins]
     111        self.existing_clrpin = self.clrpins[0]
     112        self.existing_clrpin
     113        parts = self.existing_clrpin.split('-')[1:]
     114        self.existing_clrseries, self.existing_clrnumber = parts
    105115
    106116        # Populate university
     
    310320        return
    311321
    312     def test_student_access(self):
    313         # Students can access their own objects
    314         # and can perform actions
     322    def test_student_change_password(self):
     323        # Students can change the password
    315324        self.browser.open(self.login_path)
    316325        self.browser.getControl(name="form.login").value = self.test_student_id
     
    350359    def test_setpassword(self):
    351360        # Set password for first-time access
    352         # Add student with subobjects (done by addStudent)
    353361        student = Student()
    354362        student.reg_number = u'123456'
     
    358366        student_path = 'http://localhost/app/students/%s' % test_student_id
    359367        self.browser.open(setpassword_path)
    360         self.browser.getControl(name="ac_series").value = self.existing_series
    361         self.browser.getControl(name="ac_number").value = self.existing_number
     368        self.browser.getControl(name="ac_series").value = self.existing_pwdseries
     369        self.browser.getControl(name="ac_number").value = self.existing_pwdnumber
    362370        self.browser.getControl(name="reg_number").value = '123456'
    363371        self.browser.getControl("Show").click()
     
    368376        self.browser.getControl(name="form.login").value = test_student_id
    369377        self.browser.getControl(
    370             name="form.password").value = self.existing_number
     378            name="form.password").value = self.existing_pwdnumber
    371379        self.browser.getControl("Login").click()
    372380        self.assertEqual(self.browser.url, student_path)
    373381        self.assertTrue('You logged in' in self.browser.contents)
    374382        return
     383
     384    def test_student_access(self):
     385        # Students can access their own objects
     386        # and can perform actions
     387        student = self.app['students'][self.test_student_id]
     388        IWorkflowInfo(student).fireTransition('admit')
     389        self.browser.open(self.login_path)
     390        self.browser.getControl(name="form.login").value = self.test_student_id
     391        self.browser.getControl(name="form.password").value = 'spwd'
     392        self.browser.getControl("Login").click()
     393        # Student can view the clearance data
     394        self.browser.getLink("Clearance Data").click()
     395        # Student can't open clearance edit form before starting clearance
     396        self.browser.open(self.student_path + '/cedit')
     397        self.assertMatches('...The requested form is locked...',
     398                           self.browser.contents)
     399        self.browser.getLink("Clearance Data").click()
     400        self.browser.getLink("Start clearance").click()
     401        self.browser.getControl(name="ac_series").value = self.existing_clrseries
     402        self.browser.getControl(name="ac_number").value = self.existing_clrnumber
     403        self.browser.getControl("Start").click()
     404        self.assertMatches('...Clearance process is started...',
     405                           self.browser.contents)
     406        self.browser.getControl(name="form.date_of_birth").value = '09/10/1961'
     407        self.browser.getControl("Save", index=0).click()
     408        # Student can view the clearance data
     409        self.browser.getLink("Clearance Data").click()
     410        # and go back to the edit form
     411        self.browser.getLink("Edit").click()
     412        self.browser.getControl("Save and request clearance").click()
     413        self.assertMatches('...Clearance has been requested...',
     414                           self.browser.contents)
     415        # Student can't reopen clearance form after requesting clearance
     416        self.browser.open(self.student_path + '/cedit')
     417        self.assertMatches('...The requested form is locked...',
     418                           self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.