Ignore:
Timestamp:
20 Jul 2012, 08:56:34 (12 years ago)
Author:
Henrik Bettermann
Message:

Disable states and transitions which are not allowed for pg students. Not yet fully tested.

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

Legend:

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

    r8920 r9028  
    2323import unittest
    2424import datetime
     25import grok
    2526from time import time
     27from zope.event import notify
    2628from zope.component import createObject
    2729from zope.component.hooks import setSite, clearSite
    2830from zope.interface.verify import verifyClass, verifyObject
     31from hurry.workflow.interfaces import IWorkflowState
    2932
    3033from waeup.kofa.app import University
     
    178181    def setup_student(self, student):
    179182        # set predictable values for `student`
    180         student.matric_number = u'M123456'
     183        student.matric_number = u'234'
    181184        student.adm_code = u'my adm code'
    182185        student.clearance_locked = False
    183186        student.clr_code = u'my clr code'
    184187        student.perm_address = u'Studentroad 21\nLagos 123456\n'
    185         student.reg_number = u'123456'
    186         student.student_id = u'A111111'
     188        student.reg_number = u'123'
    187189        student.firstname = u'Anna'
    188190        student.lastname = u'Tester'
     
    240242
    241243
    242 class StudentProcessorTest(FunctionalTestCase):
     244class StudentProcessorTest(StudentImportExportSetup):
    243245
    244246    layer = FunctionalLayer
     
    246248    def setUp(self):
    247249        super(StudentProcessorTest, self).setUp()
    248         # Setup a sample site for each test
    249         app = University()
    250         self.dc_root = tempfile.mkdtemp()
    251         app['datacenter'].setStoragePath(self.dc_root)
    252 
    253         # Prepopulate the ZODB...
    254         self.getRootFolder()['app'] = app
    255         # we add the site immediately after creation to the
    256         # ZODB. Catalogs and other local utilities are not setup
    257         # before that step.
    258         self.app = self.getRootFolder()['app']
    259         # Set site here. Some of the following setup code might need
    260         # to access grok.getSite() and should get our new app then
    261         setSite(app)
    262250
    263251        # Add student with subobjects
    264252        student = Student()
    265         student.firstname = u'Anna'
    266         student.lastname = u'Tester'
    267         student.reg_number = u'123'
    268         student.matric_number = u'234'
    269253        self.app['students'].addStudent(student)
     254        student = self.setup_student(student)
     255        notify(grok.ObjectModifiedEvent(student))
    270256        self.student = self.app['students'][student.student_id]
     257
    271258        self.processor = StudentProcessor()
    272259        self.workdir = tempfile.mkdtemp()
     
    292279        open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES)
    293280
    294     def tearDown(self):
    295         super(StudentProcessorTest, self).tearDown()
    296         shutil.rmtree(self.workdir)
    297         shutil.rmtree(self.dc_root)
    298         clearSite()
    299         return
    300 
    301281    def test_interface(self):
    302282        # Make sure we fulfill the interface contracts.
     
    350330        self.assertEqual(initial_stud_id, new_stud_id)
    351331        return
     332
     333    def test_checkUpdateRequirements(self):
     334        # Make sure that pg students can't be updated with wrong transition.
     335        err = self.processor.checkUpdateRequirements(self.student,
     336            dict(reg_number='1', state='returning'), self.app)
     337        self.assertTrue(err is None)
     338        self.certificate.study_mode = 'pg_ft'
     339        err = self.processor.checkUpdateRequirements(self.student,
     340            dict(reg_number='1', state='returning'), self.app)
     341        self.assertEqual(err, 'State not allowed (pg student).')
     342        IWorkflowState(self.student).setState('school fee paid')
     343        err = self.processor.checkUpdateRequirements(self.student,
     344            dict(reg_number='1', transition='reset6'), self.app)
     345        self.assertEqual(err, 'Transition not allowed (pg student).')
     346        err = self.processor.checkUpdateRequirements(self.student,
     347            dict(reg_number='1', transition='register_courses'), self.app)
     348        self.assertEqual(err, 'Transition not allowed (pg student).')
     349
    352350
    353351    def test_delEntry(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r8983 r9028  
    4848
    4949            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
    50             'Anna,Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
    51             '+234-123-12345#,123456,f,A111111,0,,created'
     50            'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",'
     51            '+234-123-12345#,123,f,A111111,0,,created'
    5252            in result
    5353            )
     
    6868
    6969            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
    70             'Anna,Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
    71             '+234-123-12345#,123456,f,A111111,0,,created'
     70            'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",'
     71            '+234-123-12345#,123,f,A111111,0,,created'
    7272            in result
    7373            )
     
    8787
    8888            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
    89             'Anna,Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
    90             '+234-123-12345#,123456,f,A111111,0,,created'
     89            'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",'
     90            '+234-123-12345#,123,f,A111111,0,,created'
    9191            in result
    9292            )
Note: See TracChangeset for help on using the changeset viewer.