Changeset 8906


Ignore:
Timestamp:
4 Jul 2012, 07:36:41 (12 years ago)
Author:
Henrik Bettermann
Message:

Do not replicate tests already performed in kofacustom.nigeria.

File:
1 edited

Legend:

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

    r8720 r8906  
    2929from waeup.kofa.interfaces import (
    3030    IExtFileStore, IFileStoreNameChooser)
    31 from waeup.kofa.students.batching import StudentProcessor
    3231from waeup.kofa.students.interfaces import IStudentsUtils
    33 from waeup.uniben.students.batching import CustomStudentProcessor
    3432from waeup.uniben.testing import FunctionalLayer
    35 from waeup.uniben.students.interfaces import (
    36     ICustomStudentStudyCourse, ICustomStudent,
    37     ICustomStudentStudyLevel, ICustomCourseTicket)
    38 
    39 
    40 STUDENT_SAMPLE_DATA = open(
    41     os.path.join(os.path.dirname(__file__), 'sample_student_data.csv'),
    42     'rb').read()
    43 
    44 STUDENT_HEADER_FIELDS = STUDENT_SAMPLE_DATA.split(
    45     '\n')[0].split(',')
     33
    4634
    4735class StudentProcessorTest(FunctionalTestCase):
     
    6856        setSite(app)
    6957
    70         self.processor_base = StudentProcessor()
    71         self.processor = CustomStudentProcessor()
    72         self.workdir = tempfile.mkdtemp()
    73         self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv')
    74         open(self.csv_file, 'wb').write(STUDENT_SAMPLE_DATA)
    7558
    7659    def tearDown(self):
     
    8164        return
    8265
    83     def test_import(self):
    84         # We have an empty column 'date_of_birth' in  the import file.
    85         # The original processor will fail because 'date_of_birth' is required
    86         # in the base package.
    87         num, num_warns, fin_file, fail_file = self.processor_base.doImport(
    88             self.csv_file, STUDENT_HEADER_FIELDS)
    89         self.assertEqual(num_warns,3)
    90         assert len(self.app['students'].keys()) == 0
    91         # The customized processor does not complain since 'date_of_birth' is
    92         # not required in the custom package.
    93         num, num_warns, fin_file, fail_file = self.processor.doImport(
    94             self.csv_file, STUDENT_HEADER_FIELDS)
    95         #print open(fail_file).read()
    96         self.assertEqual(num_warns,0)
    97         assert len(self.app['students'].keys()) == 3
    98         shutil.rmtree(os.path.dirname(fin_file))
    99 
    100 
    10166class StudentUITests(StudentsFullSetup):
    10267    """Tests for customized student class views and pages
     
    10469
    10570    layer = FunctionalLayer
    106 
    107     def test_classes(self):
    108         # Let's see if objects created in the customized
    109         # portal really implement the customized interfaces
    110         verify.verifyObject(ICustomStudent, self.student)
    111         verify.verifyObject(
    112             ICustomStudentStudyCourse, self.student['studycourse'])
    113         studylevel = createObject(u'waeup.StudentStudyLevel')
    114         verify.verifyObject(ICustomStudentStudyLevel, studylevel)
    115         ticket = createObject(u'waeup.CourseTicket')
    116         verify.verifyObject(ICustomCourseTicket, ticket)
    117         IWorkflowState(self.student).setState('returning')
    118         # Let's see if next_session_allowed works as expected
    119         # A, ug_ft, 100
    120         self.assertTrue(self.student['studycourse'].next_session_allowed)
    121         # O, ug_ft, 100
    122         self.student['studycourse'].current_verdict = 'O'
    123         self.assertTrue(self.student['studycourse'].next_session_allowed)
    124         # O, ug_ft, 200
    125         self.student['studycourse'].current_level = 200
    126         self.assertFalse(self.student['studycourse'].next_session_allowed)
    127         # O, de_ft, 200
    128         self.student['studycourse'].certificate.study_mode = 'de_ft'
    129         self.assertTrue(self.student['studycourse'].next_session_allowed)
    130         # O, ph_ft, 300
    131         self.student['studycourse'].certificate.study_mode = 'ph_ft'
    132         self.student['studycourse'].current_level = 300
    133         self.assertTrue(self.student['studycourse'].next_session_allowed)
    134         # O, ph_ft, 400
    135         self.student['studycourse'].current_level = 400
    136         self.assertFalse(self.student['studycourse'].next_session_allowed)
    137 
    138         # Now we convert the certificate into a postgraduate certificate
    139         IWorkflowState(self.student).setState('school fee paid')
    140         self.certificate.study_mode = 'pg_ft'
    141         # ... and voila next session registration is allowed
    142         self.assertTrue(self.student['studycourse'].next_session_allowed)
    143 
    144     def test_manage_access(self):
    145         # Managers can access the pages of students
    146         # and can perform actions
    147         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    148         # The student created in the base package is an ug student
    149         self.browser.open(self.student_path)
    150         self.browser.getLink("Clearance Data").click()
    151         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    152         self.assertEqual(self.browser.url, self.clearance_path)
    153         self.browser.getLink("Manage").click()
    154         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    155         self.assertEqual(self.browser.url, self.manage_clearance_path)
    156         self.browser.getControl(name="form.date_of_birth").value = '09/10/1961'
    157         self.browser.getControl("Save").click()
    158         self.assertMatches('...Form has been saved...',
    159                            self.browser.contents)
    160         self.assertMatches('...First Sitting Record...',
    161                            self.browser.contents)
    162         # Managers can open clearance slip of ug students
    163         self.browser.open(self.student_path + '/clearance.pdf')
    164         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    165         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    166         # There is no pg field in the clearance form
    167         self.assertFalse('Second Higher Education Record'
    168             in self.browser.contents)
    169         # Now we change the study mode ...
    170         self.certificate.study_mode = 'pg_ft'
    171         self.browser.open(self.clearance_path)
    172         # ... and additional pg clearance fields appear
    173         self.assertMatches('...Second Higher Education Record...',
    174                            self.browser.contents)
    175         # But also fields from the ug form are displayed
    176         self.assertMatches('...First Sitting Record...',
    177                            self.browser.contents)
    178         # Managers can open clearance slip of pg students
    179         self.browser.open(self.student_path + '/clearance.pdf')
    180         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    181         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    18271
    18372    def test_manage_payments(self):
     
    281170        self.assertMatches('...Session configuration object is not...',
    282171                           self.browser.contents)
    283 
    284     def test_student_access(self):
    285         # Students can edit clearance data
    286         IWorkflowState(self.student).setState('cleared')
    287         self.student.clearance_locked = False
    288         self.browser.open(self.login_path)
    289         self.browser.getControl(name="form.login").value = self.student_id
    290         self.browser.getControl(name="form.password").value = 'spwd'
    291         self.browser.getControl("Login").click()
    292         # Even in state admitted students can't change the portait if
    293         # application slip exists.
    294         IWorkflowState(self.student).setState('admitted')
    295         self.browser.open(self.student_path)
    296         self.assertTrue('Change portrait' in self.browser.contents)
    297         file_store = getUtility(IExtFileStore)
    298         applicant_slip = 'My application slip'
    299         file_id = IFileStoreNameChooser(self.student).chooseName(
    300             attr="application_slip.pdf")
    301         file_store.createFile(file_id, StringIO(applicant_slip))
    302         self.browser.open(self.student_path)
    303         self.assertFalse('Change portrait' in self.browser.contents)
    304         self.browser.open(self.student_path + '/change_portrait')
    305         self.assertTrue('The requested form is locked' in self.browser.contents)
    306         # Student can view and edit clearance data
    307         self.browser.getLink("Clearance Data").click()
    308         self.browser.getLink("Edit").click()
    309         self.assertTrue('Save' in self.browser.contents)
    310172
    311173    def test_get_returning_data(self):
Note: See TracChangeset for help on using the changeset viewer.