Ignore:
Timestamp:
4 Jul 2014, 07:46:16 (10 years ago)
Author:
Henrik Bettermann
Message:

Filter payment ticket data exports by specifying the payment_date period.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students/tests
Files:
2 edited

Legend:

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

    r11676 r11730  
    32333233        return job_id
    32343234
     3235    def test_datacenter_export(self):
     3236        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     3237        self.browser.open('http://localhost/app/datacenter/@@exportconfig')
     3238        self.browser.getControl(name="exporter").value = ['bursary']
     3239        self.browser.getControl(name="session").value = ['2004']
     3240        self.browser.getControl(name="level").value = ['100']
     3241        self.browser.getControl(name="mode").value = ['ug_ft']
     3242        self.browser.getControl(name="payments_start").value = '13/12/2012'
     3243        self.browser.getControl(name="payments_end").value = '14/12/2012'
     3244        self.browser.getControl("Create CSV file").click()
     3245
     3246        # When the job is finished and we reload the page...
     3247        job_id = self.wait_for_export_job_completed()
     3248        # ... the csv file can be downloaded ...
     3249        self.browser.open('http://localhost/app/datacenter/@@export')
     3250        self.browser.getLink("Download").click()
     3251        self.assertEqual(self.browser.headers['content-type'],
     3252            'text/csv; charset=UTF-8')
     3253        self.assertTrue(
     3254            'filename="WAeUP.Kofa_bursary_%s.csv' % job_id in
     3255            self.browser.headers['content-disposition'])
     3256        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     3257        job_id = self.app['datacenter'].running_exports[0][0]
     3258        # ... and discarded
     3259        self.browser.open('http://localhost/app/datacenter/@@export')
     3260        self.browser.getControl("Discard").click()
     3261        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     3262        # Creation, downloading and discarding is logged
     3263        logfile = os.path.join(
     3264            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     3265        logcontent = open(logfile).read()
     3266        self.assertTrue(
     3267            'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig '
     3268            '- exported: bursary (2004, 100, ug_ft, None, None, '
     3269            '13/12/2012, 14/12/2012), job_id=%s'
     3270            % job_id in logcontent
     3271            )
     3272        self.assertTrue(
     3273            'zope.mgr - browser.pages.ExportCSVView '
     3274            '- downloaded: WAeUP.Kofa_bursary_%s.csv, job_id=%s'
     3275            % (job_id, job_id) in logcontent
     3276            )
     3277        self.assertTrue(
     3278            'zope.mgr - browser.pages.ExportCSVPage '
     3279            '- discarded: job_id=%s' % job_id in logcontent
     3280            )
     3281
     3282    def test_payment_dates(self):
     3283        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     3284        self.browser.open('http://localhost/app/datacenter/@@exportconfig')
     3285        self.browser.getControl(name="exporter").value = ['bursary']
     3286        self.browser.getControl(name="session").value = ['2004']
     3287        self.browser.getControl(name="level").value = ['100']
     3288        self.browser.getControl(name="mode").value = ['ug_ft']
     3289        self.browser.getControl(name="payments_start").value = '13/12/2012'
     3290        # If one payment date is missing, an error message appears
     3291        self.browser.getControl(name="payments_end").value = ''
     3292        self.browser.getControl("Create CSV file").click()
     3293        self.assertTrue('Payment dates do not match format d/m/Y'
     3294            in self.browser.contents)
     3295
    32353296    def test_faculties_export(self):
    32363297        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    32433304        self.browser.getControl(name="level").value = ['100']
    32443305        self.browser.getControl(name="mode").value = ['ug_ft']
     3306        self.browser.getControl(name="payments_start").value = '13/12/2012'
     3307        self.browser.getControl(name="payments_end").value = '14/12/2012'
    32453308        self.browser.getControl("Create CSV file").click()
    32463309
     
    32673330        self.assertTrue(
    32683331            'zope.mgr - students.browser.FacultiesExportJobContainerJobConfig '
    3269             '- exported: bursary (2004, 100, ug_ft, None, None), job_id=%s'
     3332            '- exported: bursary (2004, 100, ug_ft, None, None, '
     3333            '13/12/2012, 14/12/2012), job_id=%s'
    32703334            % job_id in logcontent
    32713335            )
     
    32903354        self.browser.getControl(name="level").value = ['100']
    32913355        self.browser.getControl(name="mode").value = ['ug_ft']
     3356        # The testbrowser does not hide the payment period fields, but
     3357        # values are ignored when using the students exporter.
     3358        self.browser.getControl(name="payments_start").value = '13/12/2012'
     3359        self.browser.getControl(name="payments_end").value = '14/12/2012'
    32923360        self.browser.getControl("Create CSV file").click()
    32933361
     
    33143382        self.assertTrue(
    33153383            'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig '
    3316             '- exported: students (2004, 100, ug_ft, dep1, None), job_id=%s'
     3384            '- exported: students (2004, 100, ug_ft, dep1, None, '
     3385            '13/12/2012, 14/12/2012), job_id=%s'
    33173386            % job_id in logcontent
    33183387            )
     
    33603429        self.assertTrue(
    33613430            'zope.mgr - students.browser.CertificateExportJobContainerJobConfig '
    3362             '- exported: students (2004, 100, None, None, CERT1), job_id=%s'
     3431            '- exported: students (2004, 100, None, None, CERT1, None, None), '
     3432            'job_id=%s'
    33633433            % job_id in logcontent
    33643434            )
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r11702 r11730  
    761761        return
    762762
     763    def test_export_filtered_by_date(self):
     764        # payments_start and payments_end are being ignored
     765        self.setup_student(self.student)
     766        self.app['students'].addStudent(self.student)
     767        notify(grok.ObjectModifiedEvent(self.student))
     768        exporter = StudentPaymentsExporter()
     769        # A key xxx does not exist
     770        self.assertRaises(
     771            KeyError, exporter.export_filtered, self.app, self.outfile,
     772            current_session=None,
     773            current_level=None, xxx='nonsense')
     774        # payments_start and payments_end do exist but must match format '%Y-%m-%d'
     775        self.assertRaises(
     776            ValueError, exporter.export_filtered, self.app, self.outfile,
     777            current_session=None, current_level=None,
     778            payments_start='nonsense', payments_end='nonsense')
     779        # If they match the format they are ignored by get_filtered and the
     780        # exporter works properly
     781        exporter.export_filtered(
     782            self.app, self.outfile,
     783            current_session=None, current_level=None,
     784            payments_start='01/04/2012', payments_end='02/04/2012')
     785        result = open(self.outfile, 'rb').read()
     786        self.assertEqual(
     787            result,
     788            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     789            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
     790            'r_code,r_desc,student_id,state,current_session\r\n'
     791
     792            '666,12.12,2012-04-01 13:12:01,schoolfee,1,my-id,'
     793            'p-item,100,2012,paid,2012-04-01 14:12:01,12.12,'
     794            'r-code,,A111111,created,2012\r\n'
     795            )
     796        # no results if payment_date is outside the given period
     797        exporter.export_filtered(
     798            self.app, self.outfile,
     799            current_session=None, current_level=None,
     800            payments_start='31/03/2012', payments_end='01/04/2012')
     801        result = open(self.outfile, 'rb').read()
     802        self.assertEqual(
     803            result,
     804            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     805            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
     806            'r_code,r_desc,student_id,state,current_session\r\n'
     807            )
     808        exporter.export_filtered(
     809            self.app, self.outfile,
     810            current_session=None, current_level=None,
     811            payments_start='02/04/2012', payments_end='03/04/2012')
     812        result = open(self.outfile, 'rb').read()
     813        self.assertEqual(
     814            result,
     815            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     816            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
     817            'r_code,r_desc,student_id,state,current_session\r\n'
     818            )
     819        return
     820
    763821class BursaryDataExporterTest(StudentImportExportSetup):
    764822
Note: See TracChangeset for help on using the changeset viewer.