Changeset 8848 for main/waeup.kofa/trunk


Ignore:
Timestamp:
29 Jun 2012, 11:26:59 (12 years ago)
Author:
Henrik Bettermann
Message:

Add view which executes the mandate.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/mandates
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py

    r8847 r8848  
    6060        if self.expires < datetime.utcnow():
    6161            msg = _('Mandate expired.')
    62         if self.category == 'student_password':
     62        elif self.category == 'student_password':
    6363            if self._setStudentPassword():
    6464                msg = _('Password has been successfully set.')
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py

    r8847 r8848  
    2121import tempfile
    2222import shutil
     23from zope.testbrowser.testing import Browser
    2324from datetime import datetime, timedelta
    2425from zope.interface.verify import verifyClass, verifyObject
     
    7576        setSite(app)
    7677
     78        self.browser = Browser()
     79        self.browser.handleErrors = False
     80
    7781    def tearDown(self):
    7882        super(MandatesContainerTestCase, self).tearDown()
     
    9599        msg = mandate.execute()
    96100        self.assertEqual(msg, u'Mandate expired.')
    97         # Ad and execute a perfect mandate
    98         mandate = Mandate(days=0)
     101        # Add and execute a perfect mandate
     102        mandate = Mandate()
    99103        mandate.category = 'student_password'
    100104        mandate.params['student_id'] = student.student_id
     
    120124        self.assertEqual(len(self.app['mandates'].keys()), 1)
    121125        self.assertEqual([i for i in self.app['mandates'].keys()], [u'23456'])
     126
     127    def test_browser(self):
     128        student = createObject('waeup.Student')
     129        self.app['students'].addStudent(student)
     130        mandate = Mandate()
     131        mandate.category = 'student_password'
     132        mandate.params['student_id'] = student.student_id
     133        mandate.params['password'] = 'mypwd1'
     134        self.app['mandates'].addMandate(mandate)
     135        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
     136            % mandate.mandate_id)
     137        # Password has been set.
     138        self.assertTrue('Password has been successfully set.'
     139            in self.browser.contents)
     140        self.assertTrue(IUserAccount(student).checkPassword('mypwd1'))
     141        # All mandates have been removed.
     142        self.assertEqual(len(self.app['mandates'].keys()), 0)
Note: See TracChangeset for help on using the changeset viewer.