Ignore:
Timestamp:
12 Sep 2011, 08:27:14 (13 years ago)
Author:
Henrik Bettermann
Message:

Add test for setting password with the SetPassword? page. This additional test causes the well known AssertionError? in /utsils/tests/test_logger.py", line 401. I don't know why.

File:
1 edited

Legend:

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

    r6702 r6714  
    3434from hurry.workflow.interfaces import IWorkflowInfo
    3535from waeup.sirp.testing import (
    36     FunctionalLayer, FunctionalTestCase, remove_logger
     36    FunctionalLayer, FunctionalTestCase, remove_logger,
     37    remove_new_loggers,
    3738    )
    3839from waeup.sirp.app import University
     
    9798        self.history_student_path = self.student_path + '/history'
    9899
     100        # Create 5 access codes with prefix'PWD' and cost 9.99 each
     101        pin_container = self.app['accesscodes']
     102        pin_container.createBatch(
     103            datetime.now(), 'some_userid', 'PWD', 9.99, 5)
     104        pins = pin_container[pin_container.keys()[0]].values()
     105        self.pins = [x.representation for x in pins]
     106        self.existing_pin = self.pins[0]
     107        parts = self.existing_pin.split('-')[1:]
     108        self.existing_series, self.existing_number = parts
     109
    99110        # Populate university
    100111        certificate = createObject('waeup.Certificate')
     
    257268        # Students can access their own objects
    258269        # and can perform actions
    259         remove_logger('waeup.sirp.app.students')
     270        remove_new_loggers(self.functional_old_loggers)
    260271        self.browser.open(self.login_path)
    261272        self.browser.getControl(name="form.login").value = self.test_student_id
     
    285296        self.assertEqual(self.browser.url, self.student_path)
    286297        self.assertTrue('You logged in' in self.browser.contents)
    287 
    288         return
     298        return
     299
     300    def test_setpassword(self):
     301        # Set password for first-time access
     302        # Add student with subobjects (done by addStudent)
     303        student = Student()
     304        student.reg_number = u'123456'
     305        student.name = u'Klaus Tester'
     306        test_student_id = self.app['students'].addStudent(student)
     307        setpassword_path = 'http://localhost/app/setpassword'
     308        student_path = 'http://localhost/app/students/%s' % test_student_id
     309        self.browser.open(setpassword_path)
     310        self.browser.getControl(name="form.acseries").value = self.existing_series
     311        self.browser.getControl(name="form.acnumber").value = self.existing_number
     312        self.browser.getControl(name="form.reg_number").value = '123456'
     313        self.browser.getControl("Show").click()
     314        self.assertMatches('...Password has been set. Your Student Id is...',
     315                           self.browser.contents)
     316        # The student can login with the new credentials
     317        self.browser.open(self.login_path)
     318        self.browser.getControl(name="form.login").value = test_student_id
     319        self.browser.getControl(name="form.password").value = self.existing_number
     320        self.browser.getControl("Login").click()
     321        self.assertEqual(self.browser.url, student_path)
     322        self.assertTrue('You logged in' in self.browser.contents)
     323        return
Note: See TracChangeset for help on using the changeset viewer.