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

Add GradRawScoreReport?.

File:
1 edited

Legend:

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

    r14608 r14630  
    99from waeup.kofa.browser.tests.test_pdf import samples_dir
    1010from waeup.kofa.students.reports.raw_score_report import IRawScoreReport
    11 from waeup.aaue.students.reports.raw_score_report import CustomRawScoreReport
     11from waeup.aaue.students.reports.raw_score_report import (
     12    CustomRawScoreReport, GradRawScoreReport, IGradRawScoreReport)
    1213from waeup.aaue.testing import FunctionalLayer
    1314
     
    9899        print "Sample raw_score_report.pdf written to %s" % path
    99100        return
     101
     102
     103class GradRawScoreReportTests(CatalogTestSetup):
     104
     105    layer = FunctionalLayer
     106
     107    def setUp(self):
     108        super(GradRawScoreReportTests, self).setUp()
     109        self.course = createObject('waeup.Course')
     110        self.course.code = 'Course1'
     111        self.course.credits = 25
     112        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     113            self.course)
     114        self.app['faculties']['fac1']['dep1'].certificates[
     115            'CERT1'].addCertCourse(self.course, level=100)
     116
     117    def test_iface(self):
     118        # ensure we fullfill interface contracts
     119        obj = GradRawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
     120        verifyClass(IGradRawScoreReport, GradRawScoreReport)
     121        verifyObject(IGradRawScoreReport, obj)
     122        return
     123
     124    def test_get_courses(self):
     125        # we can get a list with one course code
     126        rsr =  GradRawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
     127        result = rsr._get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
     128        self.assertEqual(result, [u'Course1'])
     129        return
     130
     131    def test_get_students(self):
     132        # we can get a table with one student
     133        self.student['studycourse']['100']['Course1'].ca = 0
     134        rsr =  GradRawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
     135        course_codes = rsr._get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
     136        result = rsr._get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
     137        self.assertEqual(result, [])
     138        # if end level is 100, the student seems graduating and
     139        # we can get a table with one student
     140        self.certificate.end_level = 100
     141        self.student['studycourse']['100']['Course1'].credits = 91
     142        result = rsr._get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
     143        self.assertEqual(result,
     144            [(u'1234', u'TESTER, Bob', {'Course1': (70, 'A')})])
     145        self.student['studycourse']['100']['Course1'].ca = None
     146        result = rsr._get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
     147        # NER
     148        self.assertEqual(result, [])
     149        return
     150
     151    def test_create_pdf(self):
     152        self.certificate.end_level = 200
     153        self.course2 = createObject('waeup.Course')
     154        self.course2.code = 'Course2'
     155        self.course2.credits = 30
     156        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     157            self.course2)
     158        self.app['faculties']['fac1']['dep1'].certificates[
     159            'CERT1'].addCertCourse(self.course2, level=100)
     160        self.course3 = createObject('waeup.Course')
     161        self.course3.code = 'Course3'
     162        self.course3.credits = 30
     163        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     164            self.course3)
     165        self.app['faculties']['fac1']['dep1'].certificates[
     166            'CERT1'].addCertCourse(self.course3, level=100)
     167        self.app['faculties']['fac1'].officer_1 = 'Rosa Moonshine - Dean of Faculty'
     168        self.app['faculties']['fac1']['dep1'].officer_1 = 'Amalia Sunshine - Head of Department'
     169        studylevel = createObject('waeup.StudentStudyLevel')
     170        studylevel.level = 200
     171        studylevel.level_session = 2011
     172        self.student['studycourse']['200'] = studylevel
     173        ticket = createObject('waeup.CourseTicket')
     174        ticket.code = 'Course2'
     175        ticket.credits = 61
     176        ticket.score = 50
     177        ticket.ca = 10
     178        self.student['studycourse']['200']['Course2'] = ticket
     179        ticket = createObject('waeup.CourseTicket')
     180        ticket.code = 'Course3'
     181        ticket.credits = 30
     182        ticket.score = 70
     183        ticket.ca = 0
     184        self.student['studycourse']['200']['Course3'] = ticket
     185        self.assertEqual(ticket.grade, 'A')
     186        self.student.firstname = u'Osahenokese Tessy'
     187        self.student.lastname = u'Emwinyomwanru'
     188        report = GradRawScoreReport('fac1', 'dep1', 'CERT1', 2011, 200)
     189        result = report.create_pdf('JOB_ID')
     190        self.assertTrue(result.startswith('%PDF-'))
     191        path = os.path.join(samples_dir(), 'grad_raw_score_report.pdf')
     192        open(path, 'wb').write(result)
     193        print "Sample grad_raw_score_report.pdf written to %s" % path
     194        return
     195
Note: See TracChangeset for help on using the changeset viewer.