Ignore:
Timestamp:
10 Jul 2012, 09:26:36 (12 years ago)
Author:
Henrik Bettermann
Message:

Add is_foreigner property.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/interfaces.py

    r8966 r8968  
    1717##
    1818from zope import schema
     19from zope.interface import Attribute
    1920from waeup.kofa.schema import TextLineChoice
    2021from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab
     
    6263    """
    6364
     65    is_foreigner = Attribute('True if student is non-Nigerian')
     66
    6467    marit_stat = schema.Choice(
    6568        title = u'Maritual Status',
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/student.py

    r8863 r8968  
    3333    grok.provides(INigeriaStudent)
    3434
     35    @property
     36    def is_foreigner(self):
     37        return getattr(self, 'nationality') != 'NG'
    3538
    3639# Set all attributes of Student required in IStudent as field
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_student.py

    r8863 r8968  
    2121from zope.component.interfaces import IFactory
    2222from zope.interface import verify
     23from zope.schema.interfaces import ConstraintNotSatisfied
    2324from waeup.kofa.testing import FunctionalTestCase
    2425from kofacustom.nigeria.students.student import NigeriaStudent, NigeriaStudentFactory
     
    5758        implemented_by = self.factory.getInterfaces()
    5859        assert implemented_by.isOrExtends(INigeriaStudent)
     60
     61    def test_is_foreigner(self):
     62        student = self.factory()
     63        self.assertRaises(
     64            ConstraintNotSatisfied, setattr, student, 'nationality', 'XX')
     65        student.nationality = 'NG'
     66        self.assertFalse(student.is_foreigner)
     67        student.nationality = 'DE'
     68        self.assertTrue(student.is_foreigner)
    5969
    6070class NigeriaStudentStudyCourseFactoryTest(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.