Changeset 12091


Ignore:
Timestamp:
29 Nov 2014, 12:39:00 (10 years ago)
Author:
Henrik Bettermann
Message:

Add browser tests and fix.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/app.py

    r12089 r12091  
    8787        """
    8888        # lock.acquire() # lock data
    89         new_id = u'd%s' % (self._curr_app_id)
     89        new_id = u'a%s' % (self._curr_app_id)
    9090        self._curr_app_id += 1
    9191        # self._p_changed = True
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12090 r12091  
    3636    IContactForm, IObjectHistory, IIkobaObject, IIkobaUtils,
    3737    IPasswordValidator, IUserAccount,
    38     VERIFIED, REJECTED, EXPIRED)
     38    VERIFIED, REJECTED, EXPIRED, APPROVED)
    3939from waeup.ikoba.browser.layout import (
    4040    IkobaPage, IkobaEditFormPage, IkobaAddFormPage, IkobaDisplayFormPage,
     
    7070    view.flash(_('Form has been saved.'))
    7171    if fields_string:
    72         view.context.writeLogMessage(view, 'saved: %s' % fields_string)
     72        view.context.writeLogMessage(
     73            view, 'saved %s: %s' % (view.context.__name__, fields_string))
    7374    return
    7475
     
    938939    """
    939940    grok.context(ICustomerDocumentsContainer)
    940     grok.name('overview_slip.pdf')
     941    grok.name('documents_overview_slip.pdf')
    941942    grok.require('waeup.viewCustomer')
    942943    prefix = 'form'
     
    10471048    """ Page to manage the customer applications
    10481049
    1049     This manage form page is for both customers and customers officers.
     1050    This manage form page is for both customers and officers.
    10501051    """
    10511052    grok.context(IApplicationsContainer)
     
    12511252    """
    12521253    grok.context(IApplicationsContainer)
    1253     grok.name('overview_slip.pdf')
     1254    grok.name('applications_overview_slip.pdf')
    12541255    grok.require('waeup.viewCustomer')
    12551256    prefix = 'form'
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/permissions.py

    r12090 r12091  
    7373    grok.title(u'Customer Record Owner')
    7474    grok.permissions('waeup.handleCustomer', 'waeup.uploadCustomerFile',
    75                      'waeup.viewCustomer', 'waeup.editCustomerDocuments')
     75                     'waeup.viewCustomer', 'waeup.editCustomerDocuments',
     76                     'waeup.editApplications')
    7677
    7778
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12069 r12091  
    107107        document.title = u'My first document'
    108108        self.customer['documents'].addDocument(document)
     109        application = createObject('waeup.SampleApplication')
     110        application.title = u'My first application'
     111        self.customer['applications'].addApplication(application)
    109112
    110113        # Set password
     
    121124        self.history_path = self.customer_path + '/history'
    122125        self.documents_path = self.customer_path + '/documents'
     126        self.applications_path = self.customer_path + '/applications'
    123127
    124128        self.app['configuration'].carry_over = True
     
    849853        self.assertTrue(
    850854            'INFO - zope.mgr - customers.browser.DocumentManageFormPage '
    851             '- K1000000 - saved: title'
     855            '- K1000000 - saved d102: title'
    852856            in logcontent)
    853 
    854857        self.assertTrue(
    855858            'INFO - zope.mgr - customers.browser.DocumentAddFormPage '
    856859            '- K1000000 - added: PDF Document %s'
    857860            % document.document_id in logcontent)
    858 
    859861        self.assertTrue(
    860862            'INFO - zope.mgr - customers.browser.DocumentsManageFormPage '
     
    10301032        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    10311033        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    1032         path = os.path.join(samples_dir(), 'overview_slip.pdf')
     1034        path = os.path.join(samples_dir(), 'documents_overview_slip.pdf')
    10331035        open(path, 'wb').write(self.browser.contents)
    10341036        print "Sample PDF overview_slip.pdf written to %s" % path
     
    10411043        open(path, 'wb').write(self.browser.contents)
    10421044        print "Sample document_slip.pdf written to %s" % path
     1045
     1046
     1047class ApplicationUITests(CustomersFullSetup):
     1048    # Tests for CustomerSampleApplication relates views and pages
     1049
     1050    def test_manage_application(self):
     1051        # Managers can access the pages of customer applicationsconter
     1052        # and can perform actions
     1053        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1054        self.browser.open(self.customer_path)
     1055        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1056        self.assertEqual(self.browser.url, self.customer_path)
     1057        self.browser.open(self.customer_path)
     1058        self.browser.getLink("Applications").click()
     1059        self.browser.getLink("Add application").click()
     1060        self.browser.getControl(name="apptype").value = ['SampleApplication']
     1061        self.browser.getControl("Create application").click()
     1062        self.assertTrue('Sample Application created.' in self.browser.contents)
     1063        application = self.customer['applications']['a102']
     1064
     1065        # Application can be edited
     1066        self.browser.getLink("a102").click()
     1067        self.browser.getLink("Manage").click()
     1068        self.browser.getControl(name="form.title").value = 'My second app'
     1069        self.browser.getControl("Save").click()
     1070        self.assertTrue('Form has been saved.' in self.browser.contents)
     1071        self.browser.getLink("View").click()
     1072        self.assertEqual(self.browser.url, self.applications_path + '/a102/index')
     1073
     1074        # Transitions can be performed
     1075        self.browser.getLink("Transition").click()
     1076        self.browser.getControl(name="transition").value = ['submit']
     1077        self.browser.getControl("Save").click()
     1078        self.browser.getControl(name="transition").value = ['approve']
     1079        self.browser.getControl("Save").click()
     1080        self.assertEqual(application.state, 'approved')
     1081
     1082        # Applications can be removed
     1083        self.browser.getLink("Applications").click()
     1084        ctrl = self.browser.getControl(name='val_id')
     1085        ctrl.getControl(value=application.application_id).selected = True
     1086        self.browser.getControl("Remove selected", index=0).click()
     1087        self.assertTrue('Successfully removed' in self.browser.contents)
     1088
     1089        # All actions are being logged
     1090        logfile = os.path.join(
     1091            self.app['datacenter'].storage, 'logs', 'customers.log')
     1092        logcontent = open(logfile).read()
     1093        self.assertTrue(
     1094            'INFO - zope.mgr - customers.browser.ApplicationManageFormPage '
     1095            '- K1000000 - saved a102: title'
     1096            in logcontent)
     1097        self.assertTrue(
     1098            'INFO - zope.mgr - customers.browser.ApplicationAddFormPage '
     1099            '- K1000000 - added: Sample Application %s'
     1100            % application.application_id in logcontent)
     1101        self.assertTrue(
     1102            'INFO - zope.mgr - customers.browser.ApplicationsManageFormPage '
     1103            '- K1000000 - removed: %s'
     1104            % application.application_id in logcontent)
     1105
     1106    def test_edit_sample_application(self):
     1107        # Customers can manage applications under certain conditions
     1108        self.browser.open(self.login_path)
     1109        self.browser.getControl(name="form.login").value = self.customer_id
     1110        self.browser.getControl(name="form.password").value = 'cpwd'
     1111        self.browser.getControl("Login").click()
     1112        self.assertMatches(
     1113            '...You logged in...', self.browser.contents)
     1114        self.browser.getLink("Applications").click()
     1115        self.browser.getLink("Add application").click()
     1116        self.browser.getControl(name="apptype").value = ['SampleApplication']
     1117        self.browser.getControl("Create application").click()
     1118        self.assertTrue('Sample Application created.' in self.browser.contents)
     1119        application = self.customer['applications']['a102']
     1120
     1121        # Application can be edited ...
     1122        self.browser.getLink("a102").click()
     1123        self.browser.open(self.applications_path + '/a102/edit')
     1124        #self.browser.getLink("Edit").click()
     1125        self.assertTrue('The requested form is locked' in self.browser.contents)
     1126        # Customer is in wrong state
     1127        IWorkflowState(self.customer).setState(APPROVED)
     1128        self.browser.open(self.applications_path + '/a102/edit')
     1129        self.browser.getControl(name="form.title").value = 'My second app'
     1130        self.browser.getControl("Save").click()
     1131        self.assertEqual(application.title, 'My second app')
     1132        self.assertTrue('Form has been saved.' in self.browser.contents)
     1133        self.browser.getLink("View").click()
     1134        self.assertEqual(self.browser.url, self.applications_path + '/a102/index')
     1135        # Customer can submit the form. The form is also saved.
     1136        self.browser.getLink("Edit").click()
     1137        self.browser.getControl(name="form.title").value = 'My third app'
     1138        self.browser.getControl("Final Submit").click()
     1139        self.assertEqual(application.title, 'My third app')
     1140        self.assertEqual(application.state, 'submitted')
     1141        self.assertTrue('Application State: submitted for approval' in self.browser.contents)
     1142        # Customer can't edit the application once it has been submitted
     1143        self.browser.open(self.applications_path + '/a102/edit')
     1144        self.assertTrue('The requested form is locked' in self.browser.contents)
     1145
     1146    def test_view_slips(self):
     1147        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1148        # Officers can open the application overview
     1149        self.browser.open(self.customer_path + '/applications')
     1150        self.browser.getLink("Download applications overview").click()
     1151        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1152        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1153        path = os.path.join(samples_dir(), 'applications_overview_slip.pdf')
     1154        open(path, 'wb').write(self.browser.contents)
     1155        print "Sample PDF overview_slip.pdf written to %s" % path
     1156        # Officers can open application slips
     1157        self.browser.open(self.customer_path + '/applications/a101')
     1158        self.browser.getLink("Download application slip").click()
     1159        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1160        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1161        path = os.path.join(samples_dir(), 'application_slip.pdf')
     1162        open(path, 'wb').write(self.browser.contents)
     1163        print "Sample application_slip.pdf written to %s" % path
     1164
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py

    r12090 r12091  
    289289    APPMANAGE_CUSTOMER_STATES = DOCMANAGE_CUSTOMER_STATES
    290290
    291     APPMANAGE_APPLICATION_STATES = ()
     291    APPMANAGE_APPLICATION_STATES = (CREATED,)
    292292
    293293    SKIP_UPLOAD_VIEWLETS = ()
     
    378378        if show_history:
    379379            if getattr(view.context, 'history', None):
    380                 hist_translation = trans(_('Document Workflow History'), portal_language)
     380                hist_translation = trans(_('${a} Workflow History',
     381                                           mapping = {'a':view.context.translated_class_name}),
     382                                        portal_language)
    381383                data.append(Paragraph(hist_translation, HEADING_STYLE))
    382384                data.extend(creator.fromStringList(view.context.history.messages))
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r12090 r12091  
    316316    icon = 'actionicon_pdf.png'
    317317    text = _('Download documents overview')
    318     target = 'overview_slip.pdf'
     318    target = 'documents_overview_slip.pdf'
    319319
    320320
     
    390390    icon = 'actionicon_pdf.png'
    391391    text = _('Download applications overview')
    392     target = 'overview_slip.pdf'
     392    target = 'applications_overview_slip.pdf'
    393393
    394394
Note: See TracChangeset for help on using the changeset viewer.