Ignore:
Timestamp:
23 Sep 2018, 05:05:04 (6 years ago)
Author:
Henrik Bettermann
Message:

Merge with /main/waeup.kofa/branches/henrik-transcript-workflow:15127-15162

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

    r15055 r15163  
    4141from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    4242from waeup.kofa.app import University
     43from waeup.kofa.interfaces import IFileStoreNameChooser, IExtFileStore
    4344from waeup.kofa.payments.interfaces import IPayer
    4445from waeup.kofa.students.payments import StudentOnlinePayment
     
    21192120        print "Sample PDF transcript.pdf written to %s" % path
    21202121
    2121     def test_process_transcript_request(self):
     2122    def test_process_transcript(self):
    21222123        IWorkflowState(self.student).setState('transcript requested')
    21232124        notify(grok.ObjectModifiedEvent(self.student))
    2124         self.student.transcript_comment = (
     2125        self.student['studycourse'].transcript_comment = (
    21252126            u'On 07/08/2013 08:59:54 UTC K1000000 wrote:\n\nComment line 1 \n'
    21262127            'Comment line2\n\nDispatch Address:\nAddress line 1 \n'
    21272128            'Address line2\n\n')
    2128         # Create transcript officer
     2129        # Create officer with both roles
    21292130        self.app['users'].addUser('mrtranscript', 'mrtranscriptsecret')
    21302131        self.app['users']['mrtranscript'].email = 'mrtranscript@foo.ng'
     
    21322133        prmglobal = IPrincipalRoleManager(self.app)
    21332134        prmglobal.assignRoleToPrincipal('waeup.TranscriptOfficer', 'mrtranscript')
    2134         # Login as transcript officer
     2135        prmglobal.assignRoleToPrincipal('waeup.StudentsManager', 'mrtranscript')
     2136        prmglobal.assignRoleToPrincipal('waeup.TranscriptSignee', 'mrtranscript')
     2137        # Login
    21352138        self.browser.open(self.login_path)
    21362139        self.browser.getControl(name="form.login").value = 'mrtranscript'
     
    21432146            '...<div>Transcript Officer</div>...',
    21442147            self.browser.contents)
    2145         # Officer can search for students in state 'transcripr requested'
     2148        # Officer can search for students in state 'transcript requested'
    21462149        self.browser.open(self.container_path)
    2147         self.browser.getControl(name="searchtype").value = ['transcript']
     2150        self.browser.getControl(name="searchtype").value = [
     2151            'transcript requested']
    21482152        self.browser.getControl("Find student(s)").click()
    21492153        self.assertTrue('Anna Tester' in self.browser.contents)
    21502154        self.browser.getLink("K1000000").click()
    2151         self.browser.getLink("Manage transcript request").click()
     2155        self.assertFalse('Release transcript request' in self.browser.contents)
     2156        # Officers can still edit studycourse, studylevel and course tickets.
     2157        self.browser.open(self.studycourse_path + '/manage')
     2158        self.assertTrue('Undergraduate Full-Time</option>'
     2159            in self.browser.contents)
     2160        self.browser.getControl(name="form.certificate").value = ['CERT1']
     2161        self.browser.getControl(name="form.current_session").value = ['2004']
     2162        self.browser.getControl(name="form.current_verdict").value = ['A']
     2163        self.browser.getControl(name="form.entry_mode").value = ['ug_ft']
     2164        self.browser.getControl("Save").click()
     2165        self.browser.getControl(name="form.current_level").value = ['100']
     2166        self.browser.getControl("Save").click()
     2167        self.browser.getControl(name="addlevel").value = ['100']
     2168        self.browser.getControl(name="level_session").value = ['2004']
     2169        self.browser.getControl("Add study level").click()
     2170        self.browser.getLink("100").click()
     2171        self.browser.getLink("Manage").click()
     2172        self.browser.getControl(name="form.level_session").value = ['2002']
     2173        self.browser.getControl("Save").click()
     2174        self.browser.getLink("COURSE1").click()
     2175        self.browser.getLink("Manage").click()
     2176        self.browser.getControl("Save").click()
     2177        self.assertTrue('Form has been saved' in self.browser.contents)
     2178        # Officer can validate the transcript
     2179        self.browser.open(self.studycourse_path + '/transcript')
     2180        self.browser.getLink("Validate transcript").click()
     2181        # After validation all manage forms are locked.
     2182        self.browser.open(self.studycourse_path + '/manage')
     2183        self.assertTrue('The requested form is locked' in self.browser.contents)
     2184        self.assertFalse('Undergraduate Full-Time</option>'
     2185            in self.browser.contents)
     2186        self.browser.open(self.studycourse_path + '/100/manage')
     2187        self.assertTrue('The requested form is locked' in self.browser.contents)
     2188        self.browser.open(self.studycourse_path + '/100/COURSE1/manage')
     2189        self.assertTrue('The requested form is locked' in self.browser.contents)
     2190
     2191        # Transcript can be signed if officer has the permission to sign
     2192        #self.browser.open(self.studycourse_path + '/transcript')
     2193        #self.assertFalse('Sign transcript' in self.browser.contents)
     2194        #prmglobal = IPrincipalRoleManager(self.app)
     2195        #prmglobal.assignRoleToPrincipal('waeup.TranscriptSignee', 'mrtranscript')
     2196
     2197        self.browser.open(self.studycourse_path + '/transcript')
     2198        self.browser.getLink("Sign transcript electronically").click()
     2199        # Transcript signing has been logged ...
     2200        logfile = os.path.join(
     2201            self.app['datacenter'].storage, 'logs', 'students.log')
     2202        logcontent = open(logfile).read()
     2203        self.assertTrue(
     2204            'mrtranscript - students.browser.StudentTranscriptSignView - '
     2205            'K1000000 - Transcript signed' in logcontent)
     2206        # ... appears in the student's history ...
     2207        self.browser.open(self.history_path)
     2208        self.assertTrue('Transcript signed by Ruth Gordon'
     2209            in self.browser.contents)
     2210        # ... and is also stored in the transcript_signee attribute.
     2211        self.assertTrue(
     2212            u'Electronically signed by Ruth Gordon (mrtranscript) on '
     2213            in self.student['studycourse'].transcript_signees)
     2214        # Officer can release the transcript
     2215        self.browser.open(self.studycourse_path + '/transcript')
     2216        self.browser.getLink("Release transcript").click()
    21522217        self.assertTrue(' UTC K1000000 wrote:<br><br>Comment line 1 <br>'
    21532218        'Comment line2<br><br>Dispatch Address:<br>Address line 1 <br>'
     
    21552220        self.browser.getControl(name="comment").value = (
    21562221            'Hello,\nYour transcript has been sent to the address provided.')
    2157         self.browser.getControl("Save comment and mark as processed").click()
     2222        self.browser.getControl("Save comment and release transcript").click()
    21582223        self.assertTrue(
    21592224            'UTC mrtranscript wrote:\n\nHello,\nYour transcript has '
    21602225            'been sent to the address provided.\n\n'
    2161             in self.student.transcript_comment)
     2226            in self.student['studycourse'].transcript_comment)
    21622227        # The comment has been logged
    21632228        logfile = os.path.join(
     
    21652230        logcontent = open(logfile).read()
    21662231        self.assertTrue(
    2167             'mrtranscript - students.browser.StudentTranscriptRequestProcessFormPage - '
     2232            'mrtranscript - students.browser.StudentTranscriptReleaseFormPage - '
    21682233            'K1000000 - comment: Hello,<br>'
    21692234            'Your transcript has been sent to the address provided'
    21702235            in logcontent)
     2236        # File has been stored in the file system
     2237        # Check if transcript exists in the file system and is a PDF file
     2238        storage = getUtility(IExtFileStore)
     2239        file_id = IFileStoreNameChooser(
     2240            self.student).chooseName(attr='final_transcript.pdf')
     2241        pdf = storage.getFile(file_id).read()
     2242        self.assertTrue(len(pdf) > 0)
     2243        self.assertEqual(pdf[:8], '%PDF-1.4')
     2244        # Copy the file to samples_dir
     2245        path = os.path.join(samples_dir(), 'final_transcript.pdf')
     2246        open(path, 'wb').write(pdf)
     2247        print "Sample PDF final_transcript.pdf written to %s" % path
     2248        # Check if there is an transcript pdf link in UI
     2249        self.browser.open(self.student_path)
     2250        self.assertTrue('Final Transcript' in self.browser.contents)
     2251        self.browser.getLink("Final Transcript").click()
     2252        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     2253        self.assertEqual(self.browser.headers['Content-Type'],
     2254                         'application/pdf')
     2255        # Transcript views are no longer accessible
     2256        self.browser.open(self.studycourse_path)
     2257        self.assertFalse('studycourse/transcript' in self.browser.contents)
     2258        self.browser.open(self.studycourse_path + '/transcript')
     2259        self.assertTrue('Forbidden!' in self.browser.contents)
     2260        self.browser.open(self.studycourse_path + '/transcript.pdf')
     2261        self.assertTrue('Forbidden!' in self.browser.contents)
     2262        # If we reset the transcript process
     2263        # (can't be done by transcript officer), the file will be deleted
     2264        IWorkflowInfo(self.student).fireTransition('reset11')
     2265        self.browser.open(self.student_path)
     2266        self.assertFalse('Final Transcript' in self.browser.contents)
     2267        # ... and transcript process information has been removed
     2268        self.assertEqual(self.student['studycourse'].transcript_comment, None)
     2269        self.assertEqual(self.student['studycourse'].transcript_signees, None)
     2270
     2271    def test_landingpage_transcript_officer(self):
     2272        IWorkflowState(self.student).setState('transcript requested')
     2273        notify(grok.ObjectModifiedEvent(self.student))
     2274        # Create transcript officer
     2275        self.app['users'].addUser('mrtranscript', 'mrtranscriptsecret')
     2276        self.app['users']['mrtranscript'].email = 'mrtranscript@foo.ng'
     2277        self.app['users']['mrtranscript'].title = 'Ruth Gordon'
     2278        # We assign transcript officer role at faculty level
     2279        fac = self.app['faculties']['fac1']
     2280        prmlocal = IPrincipalRoleManager(fac)
     2281        prmlocal.assignRoleToPrincipal(
     2282            'waeup.local.TranscriptOfficer', 'mrtranscript')
     2283        notify(LocalRoleSetEvent(
     2284            fac, 'waeup.local.TranscriptOfficer', 'mrtranscript', granted=True))
     2285        # Login as transcript officer
     2286        self.browser.open(self.login_path)
     2287        self.browser.getControl(name="form.login").value = 'mrtranscript'
     2288        self.browser.getControl(name="form.password").value = 'mrtranscriptsecret'
     2289        self.browser.getControl("Login").click()
     2290        self.assertMatches('...You logged in...', self.browser.contents)
     2291        # Officer is on landing page and does see the transcript link
     2292        self.assertTrue(
     2293            'http://localhost/app/students/K1000000/studycourse/transcript'
     2294            in self.browser.contents)
     2295        self.browser.getLink("K1000000").click()
     2296        self.assertTrue(
     2297            'Anna Tester: Transcript Data' in self.browser.contents)
     2298        # Officer is on transcript page and can validate the transcript
     2299        self.browser.getLink("Validate transcript").click()
     2300        self.assertTrue(
     2301            '<div class="alert alert-success">Transcript validated.</div>'
     2302            in self.browser.contents)
     2303        # Officer is still on transcript page and can release the transcript
     2304        self.browser.getLink("Release transcript").click()
     2305        self.browser.getControl("Save comment and release transcript").click()
     2306        self.assertTrue(
     2307            '<div class="alert alert-success">'
     2308            'Transcript released and final transcript file saved.</div>'
     2309            in self.browser.contents)
     2310
     2311    def test_landingpage_transcript_signee(self):
     2312        IWorkflowState(self.student).setState('transcript validated')
     2313        notify(grok.ObjectModifiedEvent(self.student))
     2314        # Create transcript signee
     2315        self.app['users'].addUser('mrtranscript', 'mrtranscriptsecret')
     2316        self.app['users']['mrtranscript'].email = 'mrtranscript@foo.ng'
     2317        self.app['users']['mrtranscript'].title = 'Ruth Gordon'
     2318        # We assign transcript officer role at faculty level
     2319        fac = self.app['faculties']['fac1']
     2320        prmlocal = IPrincipalRoleManager(fac)
     2321        prmlocal.assignRoleToPrincipal(
     2322            'waeup.local.TranscriptSignee', 'mrtranscript')
     2323        notify(LocalRoleSetEvent(
     2324            fac, 'waeup.local.TranscriptSignee', 'mrtranscript', granted=True))
     2325        # Login as transcript officer
     2326        self.browser.open(self.login_path)
     2327        self.browser.getControl(name="form.login").value = 'mrtranscript'
     2328        self.browser.getControl(name="form.password").value = 'mrtranscriptsecret'
     2329        self.browser.getControl("Login").click()
     2330        self.assertMatches('...You logged in...', self.browser.contents)
     2331        # Officer is on landing page and does see the transcript link
     2332        self.assertTrue(
     2333            'http://localhost/app/students/K1000000/studycourse/transcript'
     2334            in self.browser.contents)
     2335        self.browser.getLink("K1000000").click()
     2336        self.assertTrue(
     2337            'Anna Tester: Transcript Data' in self.browser.contents)
     2338        # Officer is on transcript page and can sign the transcript
     2339        self.browser.getLink("Sign transcript").click()
     2340        self.assertTrue(
     2341            '<div class="alert alert-success">Transcript signed.</div>'
     2342            in self.browser.contents)
     2343        # Officer is still on transcript page
     2344        self.assertTrue(
     2345            'Anna Tester: Transcript Data' in self.browser.contents)
     2346        # Officer can sign the transcript only once
     2347        self.browser.getLink("Sign transcript").click()
     2348        self.assertTrue(
     2349            '<div class="alert alert-warning">'
     2350            'You have already signed this transcript.</div>'
     2351            in self.browser.contents)
     2352        # Signature can be seen on transcript page
     2353        self.assertTrue(
     2354            'Electronically signed by Ruth Gordon (mrtranscript) on'
     2355            in self.browser.contents)
     2356
    21712357
    21722358class StudentUITests(StudentsFullSetup):
     
    33033489            '... UTC K1000000 wrote:\n\nComment line 1 \n'
    33043490            'Comment line2\n\nDispatch Address:\nAddress line 1 \n'
    3305             'Address line2\n\n', self.student.transcript_comment)
     3491            'Address line2\n\n', self.student['studycourse'].transcript_comment)
    33063492        # The comment has been logged
    33073493        logfile = os.path.join(
     
    35723758            'firstname,flash_notice,lastname,matric_number,middlename,nationality,'
    35733759            'officer_comment,perm_address,personal_updated,phone,reg_number,'
    3574             'sex,student_id,suspended,suspended_comment,transcript_comment,'
    3575             'password,state,history,certcode,is_postgrad,current_level,'
    3576             'current_session\r\n'
     3760            'sex,student_id,suspended,suspended_comment,'
     3761            'password,state,history,certcode,is_postgrad,'
     3762            'current_level,current_session\r\n'
    35773763            ',,1981-02-04#,aa@aa.ng,,Anna,,Tester,234,,,,,,'
    3578             '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents)
     3764            '1234#,123,m,K1000000,0,,{SSHA}' in self.browser.contents)
    35793765
    35803766    def test_payment_dates(self):
     
    36783864            'firstname,flash_notice,lastname,matric_number,middlename,nationality,'
    36793865            'officer_comment,perm_address,personal_updated,phone,reg_number,'
    3680             'sex,student_id,suspended,suspended_comment,transcript_comment,'
    3681             'password,state,history,certcode,is_postgrad,current_level,'
    3682             'current_session\r\n'
     3866            'sex,student_id,suspended,suspended_comment,'
     3867            'password,state,history,certcode,is_postgrad,'
     3868            'current_level,current_session\r\n'
    36833869            ',,1981-02-04#,aa@aa.ng,,Anna,,Tester,234,,,,,,'
    3684             '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents)
     3870            '1234#,123,m,K1000000,0,,{SSHA}' in self.browser.contents)
    36853871        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
    36863872        job_id = self.app['datacenter'].running_exports[0][0]
Note: See TracChangeset for help on using the changeset viewer.