Ignore:
Timestamp:
23 Jun 2015, 05:58:58 (9 years ago)
Author:
Henrik Bettermann
Message:

Make student email field required.

A trick was needed to make test_manage_contact_student work again.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r13080 r13091  
    275275    email = schema.ASCIILine(
    276276        title = _(u'Email'),
    277         required = False,
     277        required = True,
    278278        constraint=validate_email,
    279279        )
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r13076 r13091  
    3535from zope.securitypolicy.interfaces import IPrincipalRoleManager
    3636from zope.testbrowser.testing import Browser
     37from zope.interface import implementedBy
     38from zope.schema.fieldproperty import FieldProperty
    3739from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3840from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
     
    546548        # Managers can contact student
    547549        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     550        # Remove required FieldProperty attribute first ...
     551        delattr(Student, 'email')
     552        # ... and replace by None
    548553        self.student.email = None
     554        # Now we have to add  the FieldProperty attribute again. Otherwise
     555        # many other tests below will fail.
     556        iface = list(implementedBy(Student))[0]
     557        field_property = FieldProperty(iface['email'])
     558        setattr(Student, 'email', field_property)
    549559        self.browser.open(self.student_path)
    550560        self.browser.getLink("Send email").click()
     
    24002410        self.browser.getLink("Clearance Data").click()
    24012411        self.browser.getLink("Start clearance").click()
    2402         self.student.email = None
    2403         # Uups, we forgot to fill the email fields
     2412        self.student.phone = None
     2413        # Uups, we forgot to fill the phone fields
     2414        # (email is already required in the interface, but phone not)
    24042415        self.browser.getControl("Start clearance").click()
    24052416        self.assertMatches('...Not all required fields filled...',
    24062417                           self.browser.contents)
    24072418        self.browser.open(self.student_path + '/edit_base')
    2408         self.browser.getControl(name="form.email").value = 'aa@aa.ng'
     2419        self.browser.getControl(name="form.phone.ext").value = '12345'
    24092420        self.browser.getControl("Save").click()
    24102421        self.browser.open(self.student_path + '/start_clearance')
Note: See TracChangeset for help on using the changeset viewer.