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

Add test and fix checkUpdateRequirements.

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

Legend:

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

    r9028 r9029  
    452452        """
    453453        current_level = row.get('current_level', None)
    454         if current_level == '999' and obj.state in FORBIDDEN_POSTGRAD_STATES:
     454        if current_level == '999' and \
     455            obj.__parent__.state in FORBIDDEN_POSTGRAD_STATES:
    455456            return 'Not a pg student.'
    456457        return None
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9028 r9029  
    241241
    242242
    243 
    244243class StudentProcessorTest(StudentImportExportSetup):
    245244
     
    491490        super(StudentStudyCourseProcessorTest, self).setUp()
    492491
     492        # Add student with subobjects
     493        student = Student()
     494        self.app['students'].addStudent(student)
     495        student = self.setup_student(student)
     496        notify(grok.ObjectModifiedEvent(student))
     497        self.student = self.app['students'][student.student_id]
     498
    493499        # Import students with subobjects
    494500        student_file = os.path.join(self.workdir, 'sample_student_data.csv')
     
    537543            dict(reg_number='1', current_level='100'))
    538544        self.assertEqual(len(errs),0)
     545
     546    def test_checkUpdateRequirements(self):
     547        # Make sure that pg students can't be updated with wrong transition.
     548        err = self.processor.checkUpdateRequirements(self.student['studycourse'],
     549            dict(reg_number='1', current_level='100'), self.app)
     550        self.assertTrue(err is None)
     551        err = self.processor.checkUpdateRequirements(self.student['studycourse'],
     552            dict(reg_number='1', current_level='999'), self.app)
     553        self.assertTrue(err is None)
     554        IWorkflowState(self.student).setState('returning')
     555        err = self.processor.checkUpdateRequirements(self.student['studycourse'],
     556            dict(reg_number='1', current_level='999'), self.app)
     557        self.assertEqual(err, 'Not a pg student.')
    539558
    540559    def test_import(self):
     
    672691        self.assertEqual(num_warns,2)
    673692        shutil.rmtree(os.path.dirname(fin_file))
    674        
    675693
    676694class CourseTicketProcessorTest(StudentImportExportSetup):
Note: See TracChangeset for help on using the changeset viewer.