Ignore:
Timestamp:
9 Jun 2016, 14:11:19 (8 years ago)
Author:
uli
Message:

pep8, first 1000 lines of source.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/tests/test_browser.py

    r13902 r13903  
    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
     
    5656SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp')
    5757
     58
    5859def lookup_submit_value(name, value, browser):
    5960    """Find a button with a certain value."""
     
    6667            break
    6768    return None
     69
    6870
    6971class StudentsFullSetup(FunctionalTestCase):
     
    179181        self.app['faculties']['fac1']['dep1'].courses.addCourse(
    180182            self.course)
    181         self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
    182             self.course, level=100)
     183        self.app['faculties']['fac1']['dep1'].certificates[
     184            'CERT1'].addCertCourse(self.course, level=100)
    183185
    184186        # Configure university and hostels
     
    238240
    239241
    240 
    241242class StudentsContainerUITests(StudentsFullSetup):
    242243    # Tests for StudentsContainer class views and pages
     
    275276        self.browser.getControl(name="form.reg_number").value = '123'
    276277        self.browser.getControl("Create student").click()
    277         self.assertTrue('Registration number exists already'
    278             in self.browser.contents)
     278        self.assertTrue(
     279            'Registration number exists already' in self.browser.contents)
    279280        self.browser.getControl(name="form.reg_number").value = '1234'
    280281        self.browser.getControl("Create student").click()
     
    424425        return
    425426
     427
    426428class OfficerUITests(StudentsFullSetup):
    427429    # Tests for Student class views and pages
     
    440442        studylevel.level = 100
    441443        cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1']
    442         self.student['studycourse'].addStudentStudyLevel(
    443             cert,studylevel)
     444        self.student['studycourse'].addStudentStudyLevel(cert, studylevel)
    444445        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    445446        self.browser.open(self.studycourse_path + '/100/manage')
    446         self.assertEqual(self.browser.url, self.studycourse_path + '/100/manage')
     447        self.assertEqual(
     448            self.browser.url, self.studycourse_path + '/100/manage')
    447449        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    448450
     
    452454        self.browser.getLink("Logout").click()
    453455        self.assertTrue('You have been logged out' in self.browser.contents)
    454         # But we are still logged in since we've used basic authentication here.
    455         # Wikipedia says: Existing browsers retain authentication information
    456         # until the tab or browser is closed or the user clears the history.
    457         # HTTP does not provide a method for a server to direct clients to
    458         # discard these cached credentials. This means that there is no
    459         # effective way for a server to "log out" the user without closing
    460         # the browser. This is a significant defect that requires browser
    461         # 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 ...
    462466        self.assertTrue('Manager' in self.browser.contents)
    463467
     
    570574        self.browser.open(self.student_path)
    571575        self.browser.getLink("Send email").click()
    572         self.browser.getControl(name="form.subject").value = 'Important subject'
     576        self.browser.getControl(
     577            name="form.subject").value = 'Important subject'
    573578        self.browser.getControl(name="form.body").value = 'Hello!'
    574579        self.browser.getControl("Send message now").click()
    575         self.assertTrue('An smtp server error occurred' in self.browser.contents)
     580        self.assertTrue(
     581            'An smtp server error occurred' in self.browser.contents)
    576582        self.student.email = 'xx@yy.zz'
    577583        self.browser.getControl("Send message now").click()
     
    622628        file_ctrl.add_file(image, filename='my_birth_certificate.jpg')
    623629        # The Save action does not upload files
    624         self.browser.getControl("Save").click() # submit form
     630        self.browser.getControl("Save").click()  # submit form
    625631        self.assertFalse(
    626632            '<a target="image" href="birth_certificate">'
     
    660666            'Uploaded file is too big' in self.browser.contents)
    661667        # we do not rely on filename extensions given by uploaders
    662         image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
     668        image = open(SAMPLE_IMAGE, 'rb')  # a jpg-file
    663669        ctrl = self.browser.getControl(name='birthcertificateupload')
    664670        file_ctrl = ctrl.mech_control
     
    681687        self.browser.getControl(
    682688            name='upload_birthcertificateupload').click()
    683         self.assertTrue('Only the following extensions are allowed'
     689        self.assertTrue(
     690            'Only the following extensions are allowed'
    684691            in self.browser.contents)
    685692
     
    692699        self.browser.getControl(
    693700            name='upload_passportuploadmanage').click()
    694         self.assertTrue('jpg file format expected'
    695             in self.browser.contents)
     701        self.assertTrue(
     702            'jpg file format expected' in self.browser.contents)
    696703        ctrl = self.browser.getControl(name='passportuploadmanage')
    697704        file_ctrl = ctrl.mech_control
     
    750757        self.assertMatches('...<span>100</span>...', self.browser.contents)
    751758        self.assertEqual(self.student['studycourse']['100'].level, 100)
    752         self.assertEqual(self.student['studycourse']['100'].level_session, 2004)
     759        self.assertEqual(
     760            self.student['studycourse']['100'].level_session, 2004)
    753761        self.browser.getControl(name="addlevel").value = ['100']
    754762        self.browser.getControl(name="level_session").value = ['2004']
     
    766774            self.app['datacenter'].storage, 'logs', 'students.log')
    767775        logcontent = open(logfile).read()
    768         self.assertTrue('zope.mgr - students.browser.StudyCourseManageFormPage '
    769                         '- K1000000 - removed: 100' in logcontent)
     776        self.assertTrue(
     777            'zope.mgr - students.browser.StudyCourseManageFormPage '
     778            '- K1000000 - removed: 100' in logcontent)
    770779        # Add level again
    771780        self.browser.getControl(name="addlevel").value = ['100']
     
    790799            self.app['datacenter'].storage, 'logs', 'students.log')
    791800        logcontent = open(logfile).read()
    792         self.assertTrue('zope.mgr - students.browser.StudyLevelManageFormPage '
    793         '- K1000000 - removed: COURSE1 at 100' in logcontent)
     801        self.assertTrue(
     802            'zope.mgr - students.browser.StudyLevelManageFormPage '
     803            '- K1000000 - removed: COURSE1 at 100' in logcontent)
    794804        self.browser.getLink("here").click()
    795805        self.browser.getControl(name="form.course").value = ['COURSE1']
     
    823833        self.assertTrue('Grade' in self.browser.contents)
    824834        self.assertTrue('Weight' in self.browser.contents)
    825         self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
    826         self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
    827         # We add another ticket to check if GPA will be correctly calculated
    828         # (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)
    829841        courseticket = createObject('waeup.CourseTicket')
    830842        courseticket.code = 'ANYCODE'
     
    838850        self.browser.open(self.student_path + '/studycourse/100')
    839851        # total credits
    840         self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[1], 23)
     852        self.assertEqual(
     853            self.student['studycourse']['100'].gpa_params_rectified[1], 23)
    841854        # weigheted credits = 3 * 10 + 4 * 13
    842         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)
    843857        # sgpa = 82 / 23
    844         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)
    845860        # Carry-over courses will be collected when next level is created
    846861        self.browser.open(self.student_path + '/studycourse/manage')
     
    890905        studylevel['COURSE1'].score = studylevel['COURSE1'].passmark + 1
    891906        # GPA is 1.
    892         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)
    893909        # Set score below passmark.
    894910        studylevel['COURSE1'].score = studylevel['COURSE1'].passmark - 1
    895911        # GPA is still 0.
    896         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)
    897914        studylevel2 = createObject(u'waeup.StudentStudyLevel')
    898915        studylevel2.level = 200
     
    904921        # The score of the carry-over course is now used for calculation of the
    905922        # GPA at level 100 ...
    906         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)
    907925        # ... but not at level 200
    908         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)
    909928        return
    910929
     
    939958        #                   self.browser.contents)
    940959
    941         # The same payment (with same p_item, p_session and p_category)
    942         # 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.
    943963        self.browser.open(self.payments_path)
    944964        self.browser.getLink("Add current session payment ticket").click()
     
    957977        # an access code is created after approval.
    958978        IWorkflowState(self.student).setState('school fee paid')
    959         self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
     979        self.assertEqual(len(self.app['accesscodes']['SFE-0']), 0)
    960980        self.browser.open(payment_url)
    961981        self.browser.getLink("Approve payment").click()
    962         self.assertMatches('...Payment approved...',
    963                           self.browser.contents)
     982        self.assertMatches(
     983            '...Payment approved...', self.browser.contents)
    964984        # Approval is logged in students.log ...
    965985        logcontent = open(logfile).read()
     
    977997        # The authorized amount has been stored in the new access code
    978998        self.assertEqual(
    979             self.app['accesscodes']['SFE-0'].values()[0].cost,40000.0)
     999            self.app['accesscodes']['SFE-0'].values()[0].cost, 40000.0)
    9801000
    9811001        # The catalog has been updated
Note: See TracChangeset for help on using the changeset viewer.