Ignore:
Timestamp:
4 Apr 2013, 10:38:36 (12 years ago)
Author:
Henrik Bettermann
Message:

Add method to revert a previously made transfer.

File:
1 edited

Legend:

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

    r9138 r10054  
    319319        self.assertEqual(len(results), 1)
    320320        assert results[0] is self.app['students'][self.student.student_id]
     321
     322        # Previous transfer can be successively reverted.
     323        self.assertEqual(self.student['studycourse_2'].certificate.code, 'CERT2')
     324        self.assertEqual(self.student['studycourse_1'].certificate.code, 'CERT1')
     325        self.assertEqual(self.student['studycourse'].certificate.code, 'CERT1')
     326        error = self.student.revert_transfer()
     327        self.assertTrue(error == None)
     328        self.assertEqual([i for i in self.student.keys()],
     329            [u'accommodation', u'payments', u'studycourse',
     330             u'studycourse_1'])
     331        self.assertEqual(self.student['studycourse_1'].certificate.code, 'CERT1')
     332        self.assertEqual(self.student['studycourse'].certificate.code, 'CERT2')
     333        # The students_catalog has been updated again.
     334        cat = queryUtility(ICatalog, name='students_catalog')
     335        results = cat.searchResults(certcode=('CERT2', 'CERT2'))
     336        results = [x for x in results]
     337        self.assertEqual(len(results), 1)
     338        assert results[0] is self.app['students'][self.student.student_id]
     339        error = self.student.revert_transfer()
     340        self.assertTrue(error == None)
     341        self.assertEqual([i for i in self.student.keys()],
     342            [u'accommodation', u'payments', u'studycourse'])
     343        self.assertEqual(self.student['studycourse'].certificate.code, 'CERT1')
     344        error = self.student.revert_transfer()
     345        self.assertTrue(error == -1)
     346        # The students_catalog has been updated again.
     347        cat = queryUtility(ICatalog, name='students_catalog')
     348        results = cat.searchResults(certcode=('CERT1', 'CERT1'))
     349        results = [x for x in results]
     350        self.assertEqual(len(results), 1)
     351        assert results[0] is self.app['students'][self.student.student_id]
     352        results = cat.searchResults(certcode=('CERT2', 'CERT2'))
     353        results = [x for x in results]
     354        self.assertEqual(len(results), 0)
     355        logcontent = open(logfile).read()
     356        self.assertTrue('system - K1000000 - transfer reverted'
     357            in logcontent)
     358        messages = ' '.join(self.student.history.messages)
     359        self.assertTrue('Transfer reverted by system' in messages)
    321360        return
    322361
Note: See TracChangeset for help on using the changeset viewer.