Changeset 15142


Ignore:
Timestamp:
18 Sep 2018, 08:07:12 (6 years ago)
Author:
Henrik Bettermann
Message:

Add tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/tests/test_batching.py

    r15066 r15142  
    665665            entry_mode='transfer'), self.app)
    666666        self.assertTrue(err is None)
     667        # In state 'transcript validated' studycourses are locked.
     668        IWorkflowState(self.student).setState('transcript validated')
     669        err = self.processor.checkUpdateRequirements(
     670            self.student['studycourse'],
     671            dict(reg_number='1', current_level=999), self.app)
     672        self.assertEqual(err, 'Studycourse is locked.')
     673        # In state 'graduated' studycourses are also locked.
     674        IWorkflowState(self.student).setState('graduated')
     675        err = self.processor.checkUpdateRequirements(
     676            self.student['studycourse'],
     677            dict(reg_number='1', current_level=999), self.app)
     678        self.assertEqual(err, 'Studycourse is locked.')
     679        # In state 'transcript released' studycourses are also locked ...
     680        IWorkflowState(self.student).setState('transcript released')
     681        err = self.processor.checkUpdateRequirements(
     682            self.student['studycourse'],
     683            dict(reg_number='1', current_level=999), self.app)
     684        self.assertEqual(err, 'Studycourse is locked.')
     685        # ... but not in state 'transcript requested'.
     686        IWorkflowState(self.student).setState('transcript requested')
     687        err = self.processor.checkUpdateRequirements(
     688            self.student['studycourse'],
     689            dict(reg_number='1', current_level=999), self.app)
     690        self.assertTrue(err is None)
    667691
    668692    def test_import(self):
     
    826850        shutil.rmtree(os.path.dirname(fin_file))
    827851
     852    def test_import_update_locked(self):
     853        num, num_warns, fin_file, fail_file = self.processor.doImport(
     854            self.csv_file, STUDYLEVEL_HEADER_FIELDS,'create')
     855        shutil.rmtree(os.path.dirname(fin_file))
     856        # In state 'transcript validated' studylevels can't be edited
     857        student = self.app['students']['X666666']
     858        IWorkflowState(student).setState('transcript validated')
     859        # Two more records could't be imported because course tickets
     860        # of X666666 are locked
     861        num, num_warns, fin_file, fail_file = self.processor.doImport(
     862            self.csv_file, STUDYLEVEL_HEADER_FIELDS,'update')
     863        self.assertEqual(num_warns,5)
     864        content = open(fail_file).read()
     865        self.assertEqual(
     866            content,
     867            'reg_number,level_verdict,level_session,matric_number,level,--ERRORS--\r\n'
     868            '1,<IGNORE>,2008,<IGNORE>,100,Studylevel is locked.\r\n'
     869            '1,<IGNORE>,2008,<IGNORE>,200,Studylevel is locked.\r\n'
     870            '1,A,2008,<IGNORE>,111,level: Invalid value\r\n'
     871            '1,A,2008,<IGNORE>,nonsense,level: Invalid value\r\n'
     872            '1,A,2008,<IGNORE>,<IGNORE>,Cannot update: no such entry\r\n'
     873            )
     874        shutil.rmtree(os.path.dirname(fin_file))
     875
    828876    def test_import_remove(self):
    829877        # We perform the same import twice,
     
    9891037            'INFO - system - K1000000 - Course ticket in 100 removed: COURSE1'
    9901038            in logcontent)
     1039
     1040    def test_import_update_locked(self):
     1041        num, num_warns, fin_file, fail_file = self.processor.doImport(
     1042            self.csv_file, COURSETICKET_HEADER_FIELDS,'create')
     1043        shutil.rmtree(os.path.dirname(fin_file))
     1044        # In state 'transcript validated' course tickets can't edited
     1045        student = self.app['students']['X666666']
     1046        IWorkflowState(student).setState('transcript validated')
     1047        num, num_warns, fin_file, fail_file = self.processor.doImport(
     1048            self.csv_file, COURSETICKET_HEADER_FIELDS,'update')
     1049        fail_file = open(fail_file).read()
     1050        # Two more records could't be imported because course tickets
     1051        # of X666666 are locked
     1052        self.assertEqual(num_warns,7)
     1053        self.assertEqual(fail_file,
     1054            'reg_number,code,mandatory,level,level_session,score,matric_number,--ERRORS--\r\n'
     1055            '1,COURSE1,True,100,<IGNORE>,1,<IGNORE>,Studycourse is locked.\r\n'
     1056            '1,COURSE1,True,200,2008,1,<IGNORE>,Studycourse is locked.\r\n'
     1057            '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,5,<IGNORE>,Cannot update: no such entry\r\n'
     1058            '1,NONSENSE,<IGNORE>,100,<IGNORE>,5,<IGNORE>,code: non-existent\r\n'
     1059            '1,COURSE1,<IGNORE>,200,2004,6,<IGNORE>,level_session: does not match 2008\r\n'
     1060            '1,COURSE1,<IGNORE>,300,2008,6,<IGNORE>,level object: does not exist\r\n'
     1061            '1,COURSE1,<IGNORE>,300,2008X,6,<IGNORE>,level_session: Invalid value\r\n')
     1062        shutil.rmtree(os.path.dirname(fin_file))
    9911063
    9921064class PaymentProcessorTest(StudentImportExportSetup):
Note: See TracChangeset for help on using the changeset viewer.