Ignore:
Timestamp:
15 Mar 2017, 12:08:35 (8 years ago)
Author:
Henrik Bettermann
Message:

Add GradSessionResultsPresentation?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py

    r14608 r14631  
    1212from waeup.kofa.browser.tests.test_pdf import samples_dir
    1313
    14 from waeup.aaue.students.reports.session_results_presentation import CustomSessionResultsPresentation
     14from waeup.aaue.students.reports.session_results_presentation import (
     15    CustomSessionResultsPresentation,
     16    GradSessionResultsPresentation,
     17    IGradSessionResultsPresentation)
    1518
    1619from waeup.aaue.testing import FunctionalLayer
     
    4043        return
    4144
    42 
    4345    def test_create_pdf(self):
    4446        self.certificate.degree = 'BA(FS)'
     
    5557
    5658 
     59class GradSessionResultsPresentationTests(CatalogTestSetup):
     60
     61    layer = FunctionalLayer
     62
     63    def test_iface(self):
     64        # ensure we fullfill interface contracts
     65        obj = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
     66        verifyClass(IGradSessionResultsPresentation, GradSessionResultsPresentation)
     67        verifyObject(IGradSessionResultsPresentation, obj)
     68        return
     69
     70    def test_get_students(self):
     71        sr = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
     72        result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100)
     73        self.assertEqual(result, [[], [], [], [], [], [], []])
     74        # if end level is 100, the student seems graduating and
     75        # we can get a table with one student
     76        self.certificate.end_level = 100
     77        self.student['studycourse']['100']['Course1'].credits = 91
     78        result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100)
     79        self.assertEqual(result, [[], [], [], [], [], [], []])
     80        self.student['studycourse']['100']['Course1'].score = 60
     81        self.student['studycourse']['100']['Course1'].ca = 10
     82        result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100)
     83        self.assertEqual(result,
     84            [[], [], [], [], [], [(u'E1000000', u'1234', u'TESTER, Bob')], []])
     85        return
     86
     87    def test_create_pdf(self):
     88        self.certificate.degree = 'BA(FS)'
     89        self.certificate.end_level = 100
     90        self.student['studycourse']['100']['Course1'].credits = 91
     91        self.student['studycourse']['100']['Course1'].ca = 0
     92        self.app['faculties']['fac1'].officer_1 = 'Rosa Moonshine - Dean of Faculty'
     93        self.app['faculties']['fac1']['dep1'].officer_1 = 'Amalia Sunshine - Head of Department'
     94        self.app['faculties']['fac1']['dep1'].officer_2 = 'Theresa Starbright - External Examiner'
     95        report = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
     96        result = report.create_pdf('JOB_ID')
     97        self.assertTrue(result.startswith('%PDF-'))
     98        path = os.path.join(samples_dir(), 'grad_session_results_presentation.pdf')
     99        open(path, 'wb').write(result)
     100        print "Sample grad_session_results_presentation.pdf written to %s" % path
     101        return
     102
Note: See TracChangeset for help on using the changeset viewer.