Ignore:
Timestamp:
14 Jun 2016, 15:55:07 (9 years ago)
Author:
Henrik Bettermann
Message:

Adjust customizations to changes in base package.

File:
1 edited

Legend:

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

    r13909 r13937  
    2121import pytz
    2222import grok
     23from StringIO import StringIO
    2324from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2425from zope.securitypolicy.interfaces import IPrincipalRoleManager
     
    3132from zope.catalog.interfaces import ICatalog
    3233from waeup.kofa.app import University
     34from waeup.kofa.interfaces import VALIDATED
    3335from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    3436from waeup.kofa.students.accommodation import BedTicket
     
    7274        return
    7375
     76UPLOAD_CSV_TEMPLATE = (
     77    'matric_number,student_id,display_fullname,level,code,level_session,'
     78    'score,ca\r\n'
     79    '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s\r\n')
     80
    7481class OfficerUITests(StudentsFullSetup):
    7582    # Tests for Student class views and pages
    7683
    7784    layer = FunctionalLayer
     85
     86    def login_as_lecturer(self):
     87        self.app['users'].addUser('mrslecturer', 'mrslecturersecret')
     88        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
     89        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
     90        # Add course ticket
     91        studylevel = createObject(u'waeup.StudentStudyLevel')
     92        studylevel.level = 100
     93        studylevel.level_session = 2004
     94        self.student['studycourse'].addStudentStudyLevel(
     95            self.certificate, studylevel)
     96        # Assign local Lecturer role for a certificate.
     97        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
     98        prmlocal = IPrincipalRoleManager(course)
     99        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
     100        notify(LocalRoleSetEvent(
     101            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
     102        # Login as lecturer.
     103        self.browser.open(self.login_path)
     104        self.browser.getControl(name="form.login").value = 'mrslecturer'
     105        self.browser.getControl(
     106            name="form.password").value = 'mrslecturersecret'
     107        self.browser.getControl("Login").click()
     108        # Store reused urls/paths
     109        self.course_url = (
     110            'http://localhost/app/faculties/fac1/dep1/courses/COURSE1')
     111        self.edit_scores_url = '%s/edit_scores' % self.course_url
     112        # Set standard parameters
     113        self.app['configuration'].current_academic_session = 2004
     114        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
     115        IWorkflowState(self.student).setState(VALIDATED)
     116
    78117
    79118    def test_gpa_calculation(self):
     
    281320        return
    282321
     322    def test_scores_csv_upload_available(self):
     323        # lecturers can upload a CSV file to set values.
     324        self.login_as_lecturer()
     325        # set value to change from
     326        self.student['studycourse']['100']['COURSE1'].score = 55
     327        self.browser.open(self.edit_scores_url)
     328        upload_ctrl = self.browser.getControl(name='uploadfile:file')
     329        upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','77'))
     330        upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv')
     331        self.browser.getControl("Update editable scores from").click()
     332        # value changed
     333        self.assertEqual(
     334            self.student['studycourse']['100']['COURSE1'].score, 65)
     335        self.assertEqual(
     336            self.student['studycourse']['100']['COURSE1'].ca, 77)
     337
    283338class StudentUITests(StudentsFullSetup):
    284339    """Tests for customized student class views and pages
     
    688743            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
    689744        self.assertTrue(
    690             'input type="text" name="scores"'
    691             in self.browser.contents)
    692         self.browser.getControl(name="scores", index=0).value = '55'
    693         self.browser.getControl(name="cas", index=0).value = '66'
    694         self.browser.getControl("Update scores").click()
     745            'input type="text" name="scores:list"'
     746            in self.browser.contents)
     747        self.browser.getControl(name="scores:list", index=0).value = '55'
     748        self.browser.getControl(name="cas:list", index=0).value = '66'
     749        self.browser.getControl("Update scores from").click()
    695750        # New score and ca has been set.
    696751        self.assertEqual(
     
    710765            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
    711766        self.assertTrue('value="55" />' in self.browser.contents)
    712         self.browser.getControl(name="scores", index=0).value = 'abc'
     767        self.browser.getControl(name="scores:list", index=0).value = 'abc'
    713768        self.browser.getControl("Update scores").click()
    714769        self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.'
     
    717772        self.browser.open(
    718773            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
    719         self.browser.getControl(name="scores", index=0).value = ''
     774        self.browser.getControl(name="scores:list", index=0).value = ''
    720775        self.browser.getControl("Update scores").click()
    721776        self.assertEqual(
Note: See TracChangeset for help on using the changeset viewer.