Ignore:
Timestamp:
10 Jun 2016, 06:42:01 (9 years ago)
Author:
uli
Message:

Merge uli-scores-upload into trunk.

Looks like subversion branching model is broken, if
branching blocks people.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk

  • main/waeup.kofa/trunk/src/waeup/kofa

  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r13898 r13904  
    11## $Id$
    2 ## 
     2##
    33## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
    44## This program is free software; you can redistribute it and/or modify
     
    66## the Free Software Foundation; either version 2 of the License, or
    77## (at your option) any later version.
    8 ## 
     8##
    99## This program is distributed in the hope that it will be useful,
    1010## but WITHOUT ANY WARRANTY; without even the implied warranty of
    1111## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1212## GNU General Public License for more details.
    13 ## 
     13##
    1414## You should have received a copy of the GNU General Public License
    1515## along with this program; if not, write to the Free Software
     
    4141from waeup.kofa.app import University
    4242from waeup.kofa.payments.interfaces import IPayer
    43 from waeup.kofa.students.interfaces import IStudentsUtils
    4443from waeup.kofa.students.student import Student
    4544from waeup.kofa.students.studylevel import StudentStudyLevel
     
    5655SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    5756SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp')
     57
    5858
    5959def lookup_submit_value(name, value, browser):
     
    6767            break
    6868    return None
     69
    6970
    7071class StudentsFullSetup(FunctionalTestCase):
     
    180181        self.app['faculties']['fac1']['dep1'].courses.addCourse(
    181182            self.course)
    182         self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
    183             self.course, level=100)
     183        self.app['faculties']['fac1']['dep1'].certificates[
     184            'CERT1'].addCertCourse(self.course, level=100)
    184185
    185186        # Configure university and hostels
     
    239240
    240241
    241 
    242242class StudentsContainerUITests(StudentsFullSetup):
    243243    # Tests for StudentsContainer class views and pages
     
    276276        self.browser.getControl(name="form.reg_number").value = '123'
    277277        self.browser.getControl("Create student").click()
    278         self.assertTrue('Registration number exists already'
    279             in self.browser.contents)
     278        self.assertTrue(
     279            'Registration number exists already' in self.browser.contents)
    280280        self.browser.getControl(name="form.reg_number").value = '1234'
    281281        self.browser.getControl("Create student").click()
     
    425425        return
    426426
     427
    427428class OfficerUITests(StudentsFullSetup):
    428429    # Tests for Student class views and pages
     
    441442        studylevel.level = 100
    442443        cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1']
    443         self.student['studycourse'].addStudentStudyLevel(
    444             cert,studylevel)
     444        self.student['studycourse'].addStudentStudyLevel(cert, studylevel)
    445445        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    446446        self.browser.open(self.studycourse_path + '/100/manage')
    447         self.assertEqual(self.browser.url, self.studycourse_path + '/100/manage')
     447        self.assertEqual(
     448            self.browser.url, self.studycourse_path + '/100/manage')
    448449        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    449450
     
    453454        self.browser.getLink("Logout").click()
    454455        self.assertTrue('You have been logged out' in self.browser.contents)
    455         # But we are still logged in since we've used basic authentication here.
    456         # Wikipedia says: Existing browsers retain authentication information
    457         # until the tab or browser is closed or the user clears the history.
    458         # HTTP does not provide a method for a server to direct clients to
    459         # discard these cached credentials. This means that there is no
    460         # effective way for a server to "log out" the user without closing
    461         # the browser. This is a significant defect that requires browser
    462         # manufacturers to support a "logout" user interface element ...
     456        # But we are still logged in since we've used basic
     457        # authentication here.  Wikipedia says: Existing browsers
     458        # retain authentication information until the tab or browser
     459        # is closed or the user clears the history.  HTTP does not
     460        # provide a method for a server to direct clients to discard
     461        # these cached credentials. This means that there is no
     462        # effective way for a server to "log out" the user without
     463        # closing the browser. This is a significant defect that
     464        # requires browser manufacturers to support a "logout" user
     465        # interface element ...
    463466        self.assertTrue('Manager' in self.browser.contents)
    464467
     
    571574        self.browser.open(self.student_path)
    572575        self.browser.getLink("Send email").click()
    573         self.browser.getControl(name="form.subject").value = 'Important subject'
     576        self.browser.getControl(
     577            name="form.subject").value = 'Important subject'
    574578        self.browser.getControl(name="form.body").value = 'Hello!'
    575579        self.browser.getControl("Send message now").click()
    576         self.assertTrue('An smtp server error occurred' in self.browser.contents)
     580        self.assertTrue(
     581            'An smtp server error occurred' in self.browser.contents)
    577582        self.student.email = 'xx@yy.zz'
    578583        self.browser.getControl("Send message now").click()
     
    623628        file_ctrl.add_file(image, filename='my_birth_certificate.jpg')
    624629        # The Save action does not upload files
    625         self.browser.getControl("Save").click() # submit form
     630        self.browser.getControl("Save").click()  # submit form
    626631        self.assertFalse(
    627632            '<a target="image" href="birth_certificate">'
     
    661666            'Uploaded file is too big' in self.browser.contents)
    662667        # we do not rely on filename extensions given by uploaders
    663         image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
     668        image = open(SAMPLE_IMAGE, 'rb')  # a jpg-file
    664669        ctrl = self.browser.getControl(name='birthcertificateupload')
    665670        file_ctrl = ctrl.mech_control
     
    682687        self.browser.getControl(
    683688            name='upload_birthcertificateupload').click()
    684         self.assertTrue('Only the following extensions are allowed'
     689        self.assertTrue(
     690            'Only the following extensions are allowed'
    685691            in self.browser.contents)
    686692
     
    693699        self.browser.getControl(
    694700            name='upload_passportuploadmanage').click()
    695         self.assertTrue('jpg file format expected'
    696             in self.browser.contents)
     701        self.assertTrue(
     702            'jpg file format expected' in self.browser.contents)
    697703        ctrl = self.browser.getControl(name='passportuploadmanage')
    698704        file_ctrl = ctrl.mech_control
     
    751757        self.assertMatches('...<span>100</span>...', self.browser.contents)
    752758        self.assertEqual(self.student['studycourse']['100'].level, 100)
    753         self.assertEqual(self.student['studycourse']['100'].level_session, 2004)
     759        self.assertEqual(
     760            self.student['studycourse']['100'].level_session, 2004)
    754761        self.browser.getControl(name="addlevel").value = ['100']
    755762        self.browser.getControl(name="level_session").value = ['2004']
     
    767774            self.app['datacenter'].storage, 'logs', 'students.log')
    768775        logcontent = open(logfile).read()
    769         self.assertTrue('zope.mgr - students.browser.StudyCourseManageFormPage '
    770                         '- K1000000 - removed: 100' in logcontent)
     776        self.assertTrue(
     777            'zope.mgr - students.browser.StudyCourseManageFormPage '
     778            '- K1000000 - removed: 100' in logcontent)
    771779        # Add level again
    772780        self.browser.getControl(name="addlevel").value = ['100']
     
    791799            self.app['datacenter'].storage, 'logs', 'students.log')
    792800        logcontent = open(logfile).read()
    793         self.assertTrue('zope.mgr - students.browser.StudyLevelManageFormPage '
    794         '- K1000000 - removed: COURSE1 at 100' in logcontent)
     801        self.assertTrue(
     802            'zope.mgr - students.browser.StudyLevelManageFormPage '
     803            '- K1000000 - removed: COURSE1 at 100' in logcontent)
    795804        self.browser.getLink("here").click()
    796805        self.browser.getControl(name="form.course").value = ['COURSE1']
     
    824833        self.assertTrue('Grade' in self.browser.contents)
    825834        self.assertTrue('Weight' in self.browser.contents)
    826         self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
    827         self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
    828         # We add another ticket to check if GPA will be correctly calculated
    829         # (and rounded)
     835        self.assertEqual(
     836            self.student['studycourse']['100']['COURSE1'].grade, 'C')
     837        self.assertEqual(
     838            self.student['studycourse']['100']['COURSE1'].weight, 3)
     839        # We add another ticket to check if GPA will be correctly
     840        # calculated (and rounded)
    830841        courseticket = createObject('waeup.CourseTicket')
    831842        courseticket.code = 'ANYCODE'
     
    839850        self.browser.open(self.student_path + '/studycourse/100')
    840851        # total credits
    841         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[1], 23)
     852        self.assertEqual(
     853            self.student['studycourse']['100'].gpa_params_rectified[1], 23)
    842854        # weigheted credits = 3 * 10 + 4 * 13
    843         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[2], 82.0)
     855        self.assertEqual(
     856            self.student['studycourse']['100'].gpa_params_rectified[2], 82.0)
    844857        # sgpa = 82 / 23
    845         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 3.565)
     858        self.assertEqual(
     859            self.student['studycourse']['100'].gpa_params_rectified[0], 3.565)
    846860        # Carry-over courses will be collected when next level is created
    847861        self.browser.open(self.student_path + '/studycourse/manage')
     
    891905        studylevel['COURSE1'].score = studylevel['COURSE1'].passmark + 1
    892906        # GPA is 1.
    893         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 1.0)
     907        self.assertEqual(
     908            self.student['studycourse']['100'].gpa_params_rectified[0], 1.0)
    894909        # Set score below passmark.
    895910        studylevel['COURSE1'].score = studylevel['COURSE1'].passmark - 1
    896911        # GPA is still 0.
    897         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 0.0)
     912        self.assertEqual(
     913            self.student['studycourse']['100'].gpa_params_rectified[0], 0.0)
    898914        studylevel2 = createObject(u'waeup.StudentStudyLevel')
    899915        studylevel2.level = 200
     
    905921        # The score of the carry-over course is now used for calculation of the
    906922        # GPA at level 100 ...
    907         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 4.0)
     923        self.assertEqual(
     924            self.student['studycourse']['100'].gpa_params_rectified[0], 4.0)
    908925        # ... but not at level 200
    909         self.assertEqual(self.student['studycourse']['200'].gpa_params_rectified[0], 0.0)
     926        self.assertEqual(
     927            self.student['studycourse']['200'].gpa_params_rectified[0], 0.0)
    910928        return
    911929
     
    940958        #                   self.browser.contents)
    941959
    942         # The same payment (with same p_item, p_session and p_category)
    943         # can be initialized a second time if the former ticket is not yet paid.
     960        # The same payment (with same p_item, p_session and
     961        # p_category) can be initialized a second time if the former
     962        # ticket is not yet paid.
    944963        self.browser.open(self.payments_path)
    945964        self.browser.getLink("Add current session payment ticket").click()
     
    958977        # an access code is created after approval.
    959978        IWorkflowState(self.student).setState('school fee paid')
    960         self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
     979        self.assertEqual(len(self.app['accesscodes']['SFE-0']), 0)
    961980        self.browser.open(payment_url)
    962981        self.browser.getLink("Approve payment").click()
    963         self.assertMatches('...Payment approved...',
    964                           self.browser.contents)
     982        self.assertMatches(
     983            '...Payment approved...', self.browser.contents)
    965984        # Approval is logged in students.log ...
    966985        logcontent = open(logfile).read()
     
    978997        # The authorized amount has been stored in the new access code
    979998        self.assertEqual(
    980             self.app['accesscodes']['SFE-0'].values()[0].cost,40000.0)
     999            self.app['accesscodes']['SFE-0'].values()[0].cost, 40000.0)
    9811000
    9821001        # The catalog has been updated
     
    13861405        IWorkflowState(self.student).setState('school fee paid')
    13871406        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1388         student = self.app['students'][self.student_id]
    13891407        self.browser.open(self.trigtrans_path)
    13901408        self.assertTrue('<option value="reset6">' in self.browser.contents)
     
    39373955        # Thew job can be discarded
    39383956        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
    3939         #job_id = self.app['datacenter'].running_exports[0][0]
    3940         job_id = self.wait_for_export_job_completed()
     3957        self.wait_for_export_job_completed()
    39413958        self.browser.open("http://localhost/app/faculties/fac1/dep1/exports")
    39423959        self.browser.getControl("Discard").click()
     
    39763993        # Thew job can be discarded
    39773994        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
    3978         #job_id = self.app['datacenter'].running_exports[0][0]
    3979         job_id = self.wait_for_export_job_completed()
     3995        self.wait_for_export_job_completed()
    39803996        self.browser.open('http://localhost/app/faculties/exports')
    39813997        self.browser.getControl("Discard").click()
Note: See TracChangeset for help on using the changeset viewer.