Ignore:
Timestamp:
30 Nov 2014, 20:49:22 (10 years ago)
Author:
Henrik Bettermann
Message:

The term 'application' should really not be used in Python-based portal software.

Replace 'application' by 'contract': batch 1

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12096 r12097  
    9696        self.product.product_id = u'SAM'
    9797        self.product.title = u'Our Samle Product'
    98         self.product.application_category = u'sample'
     98        self.product.contract_category = u'sample'
    9999        self.app['products'].addProduct(self.product)
    100100
     
    114114        document.title = u'My first document'
    115115        self.customer['documents'].addDocument(document)
    116         application = createObject('waeup.SampleApplication')
    117         application.title = u'My first application'
    118         self.customer['applications'].addApplication(application)
     116        contract = createObject('waeup.SampleContract')
     117        contract.title = u'My first contract'
     118        self.customer['contracts'].addContract(contract)
    119119
    120120        # Set password
     
    131131        self.history_path = self.customer_path + '/history'
    132132        self.documents_path = self.customer_path + '/documents'
    133         self.applications_path = self.customer_path + '/applications'
     133        self.contracts_path = self.customer_path + '/contracts'
    134134
    135135        self.app['configuration'].carry_over = True
     
    10521052
    10531053
    1054 class ApplicationUITests(CustomersFullSetup):
    1055     # Tests for CustomerSampleApplication relates views and pages
    1056 
    1057     def test_manage_application(self):
    1058         # Managers can access the pages of customer applicationsconter
     1054class ContractUITests(CustomersFullSetup):
     1055    # Tests for CustomerSampleContract relates views and pages
     1056
     1057    def test_manage_contract(self):
     1058        # Managers can access the pages of customer contractsconter
    10591059        # and can perform actions
    10601060        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    10631063        self.assertEqual(self.browser.url, self.customer_path)
    10641064        self.browser.open(self.customer_path)
    1065         self.browser.getLink("Applications").click()
    1066         self.browser.getLink("Add application").click()
    1067         self.browser.getControl(name="apptype").value = ['SampleApplication']
    1068         self.browser.getControl("Create application").click()
    1069         self.assertTrue('Sample Application created.' in self.browser.contents)
    1070         application = self.customer['applications']['a102']
    1071 
    1072         # Application can be edited
     1065        self.browser.getLink("Contracts").click()
     1066        self.browser.getLink("Add contract").click()
     1067        self.browser.getControl(name="apptype").value = ['SampleContract']
     1068        self.browser.getControl("Create contract").click()
     1069        self.assertTrue('Sample Contract created.' in self.browser.contents)
     1070        contract = self.customer['contracts']['a102']
     1071
     1072        # Contract can be edited
    10731073        self.browser.getLink("a102").click()
    10741074        self.browser.getLink("Manage").click()
     
    10781078        self.assertTrue('Form has been saved.' in self.browser.contents)
    10791079        self.browser.getLink("View").click()
    1080         self.assertEqual(self.browser.url, self.applications_path + '/a102/index')
     1080        self.assertEqual(self.browser.url, self.contracts_path + '/a102/index')
    10811081
    10821082        # Transitions can be performed
     
    10861086        self.browser.getControl(name="transition").value = ['approve']
    10871087        self.browser.getControl("Save").click()
    1088         self.assertEqual(application.state, 'approved')
    1089 
    1090         # Applications can be removed
    1091         self.browser.getLink("Applications").click()
     1088        self.assertEqual(contract.state, 'approved')
     1089
     1090        # Contracts can be removed
     1091        self.browser.getLink("Contracts").click()
    10921092        ctrl = self.browser.getControl(name='val_id')
    1093         ctrl.getControl(value=application.application_id).selected = True
     1093        ctrl.getControl(value=contract.contract_id).selected = True
    10941094        self.browser.getControl("Remove selected", index=0).click()
    10951095        self.assertTrue('Successfully removed' in self.browser.contents)
     
    11001100        logcontent = open(logfile).read()
    11011101        self.assertTrue(
    1102             'INFO - zope.mgr - customers.browser.ApplicationManageFormPage '
     1102            'INFO - zope.mgr - customers.browser.ContractManageFormPage '
    11031103            '- K1000000 - a102 - saved: title'
    11041104            in logcontent)
    11051105        self.assertTrue(
    1106             'INFO - zope.mgr - customers.browser.ApplicationAddFormPage '
    1107             '- K1000000 - added: Sample Application %s'
    1108             % application.application_id in logcontent)
    1109         self.assertTrue(
    1110             'INFO - zope.mgr - customers.browser.ApplicationsManageFormPage '
     1106            'INFO - zope.mgr - customers.browser.ContractAddFormPage '
     1107            '- K1000000 - added: Sample Contract %s'
     1108            % contract.contract_id in logcontent)
     1109        self.assertTrue(
     1110            'INFO - zope.mgr - customers.browser.ContractsManageFormPage '
    11111111            '- K1000000 - removed: %s'
    1112             % application.application_id in logcontent)
    1113 
    1114     def test_edit_sample_application(self):
     1112            % contract.contract_id in logcontent)
     1113
     1114    def test_edit_sample_contract(self):
    11151115        # We add a second product.
    11161116        product = createObject('waeup.Product')
    11171117        product.product_id = u'LIC'
    11181118        product.title = u'Our License Product'
    1119         product.application_category = u'license'
     1119        product.contract_category = u'license'
    11201120        self.app['products'].addProduct(product)
    1121         # Customers can manage applications under certain conditions
     1121        # Customers can manage contracts under certain conditions
    11221122        self.browser.open(self.login_path)
    11231123        self.browser.getControl(name="form.login").value = self.customer_id
     
    11261126        self.assertMatches(
    11271127            '...You logged in...', self.browser.contents)
    1128         self.browser.getLink("Applications").click()
    1129         self.browser.getLink("Add application").click()
    1130         self.browser.getControl(name="apptype").value = ['SampleApplication']
    1131         self.browser.getControl("Create application").click()
    1132         self.assertTrue('Sample Application created.' in self.browser.contents)
    1133         application = self.customer['applications']['a102']
    1134         # Application can be edited ...
     1128        self.browser.getLink("Contracts").click()
     1129        self.browser.getLink("Add contract").click()
     1130        self.browser.getControl(name="apptype").value = ['SampleContract']
     1131        self.browser.getControl("Create contract").click()
     1132        self.assertTrue('Sample Contract created.' in self.browser.contents)
     1133        contract = self.customer['contracts']['a102']
     1134        # Contract can be edited ...
    11351135        self.browser.getLink("a102").click()
    1136         self.browser.open(self.applications_path + '/a102/edit')
     1136        self.browser.open(self.contracts_path + '/a102/edit')
    11371137        #self.browser.getLink("Edit").click()
    11381138        self.assertTrue('The requested form is locked' in self.browser.contents)
    11391139        # Customer is in wrong state
    11401140        IWorkflowState(self.customer).setState(APPROVED)
    1141         self.browser.open(self.applications_path + '/a102/edit')
     1141        self.browser.open(self.contracts_path + '/a102/edit')
    11421142        self.browser.getControl(name="form.title").value = 'My second app'
    1143         # SAM is in the correct application_category ...
     1143        # SAM is in the correct contract_category ...
    11441144        self.assertTrue('<option value="SAM">' in self.browser.contents)
    11451145        # ... but NOTSAM not.
    11461146        self.assertFalse('<option value="LIC">' in self.browser.contents)
    11471147        # So far last_product_id is None.
    1148         self.assertTrue(self.customer['applications']['a102'].last_product_id is None)
     1148        self.assertTrue(self.customer['contracts']['a102'].last_product_id is None)
    11491149        self.browser.getControl(name="form.product").value = ['SAM']
    11501150        self.browser.getControl("Save").click()
    11511151        # After saving the form, last_product_id is set.
    1152         self.assertEqual(self.customer['applications']['a102'].last_product_id, 'SAM')
     1152        self.assertEqual(self.customer['contracts']['a102'].last_product_id, 'SAM')
    11531153        self.assertTrue('Form has been saved.' in self.browser.contents)
    11541154        # Saving the form again does not unset last_product_id
    1155         self.assertEqual(application.title, 'My second app')
    1156         self.browser.getControl("Save").click()
    1157         self.assertEqual(self.customer['applications']['a102'].last_product_id, 'SAM')
     1155        self.assertEqual(contract.title, 'My second app')
     1156        self.browser.getControl("Save").click()
     1157        self.assertEqual(self.customer['contracts']['a102'].last_product_id, 'SAM')
    11581158        self.assertTrue('Form has been saved.' in self.browser.contents)
    11591159        self.browser.getLink("View").click()
    1160         self.assertEqual(self.browser.url, self.applications_path + '/a102/index')
     1160        self.assertEqual(self.browser.url, self.contracts_path + '/a102/index')
    11611161        # Customer can submit the form. The form is also saved.
    11621162        self.browser.getLink("Edit").click()
    11631163        self.browser.getControl(name="form.title").value = 'My third app'
    11641164        self.browser.getControl("Apply now").click()
    1165         self.assertEqual(application.title, 'My third app')
    1166         self.assertEqual(application.state, 'submitted')
    1167         self.assertTrue('Application State: submitted for approval' in self.browser.contents)
    1168         # Customer can't edit the application once it has been submitted
    1169         self.browser.open(self.applications_path + '/a102/edit')
     1165        self.assertEqual(contract.title, 'My third app')
     1166        self.assertEqual(contract.state, 'submitted')
     1167        self.assertTrue('Contract State: submitted for approval' in self.browser.contents)
     1168        # Customer can't edit the contract once it has been submitted
     1169        self.browser.open(self.contracts_path + '/a102/edit')
    11701170        self.assertTrue('The requested form is locked' in self.browser.contents)
    11711171
    11721172    def test_view_slips(self):
    11731173        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1174         # Officers can open the application overview
    1175         self.browser.open(self.customer_path + '/applications')
    1176         self.browser.getLink("Download applications overview").click()
     1174        # Officers can open the contract overview
     1175        self.browser.open(self.customer_path + '/contracts')
     1176        self.browser.getLink("Download contracts overview").click()
    11771177        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    11781178        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    1179         path = os.path.join(samples_dir(), 'applications_overview_slip.pdf')
     1179        path = os.path.join(samples_dir(), 'contracts_overview_slip.pdf')
    11801180        open(path, 'wb').write(self.browser.contents)
    11811181        print "Sample PDF overview_slip.pdf written to %s" % path
    1182         # Officers can open application slips
    1183         self.browser.open(self.customer_path + '/applications/a101')
    1184         self.browser.getLink("Download application slip").click()
     1182        # Officers can open contract slips
     1183        self.browser.open(self.customer_path + '/contracts/a101')
     1184        self.browser.getLink("Download contract slip").click()
    11851185        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    11861186        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    1187         path = os.path.join(samples_dir(), 'application_slip.pdf')
     1187        path = os.path.join(samples_dir(), 'contract_slip.pdf')
    11881188        open(path, 'wb').write(self.browser.contents)
    1189         print "Sample application_slip.pdf written to %s" % path
    1190 
     1189        print "Sample contract_slip.pdf written to %s" % path
     1190
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py

    r12095 r12097  
    2727from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    2828from waeup.ikoba.customers.customer import Customer
    29 from waeup.ikoba.customers.applications import SampleApplication
     29from waeup.ikoba.customers.contracts import SampleContract
    3030
    3131
     
    6161        product.product_id = u'SAM'
    6262        product.title = u'Our Samle Product'
    63         product.application_category = u'sample'
     63        product.contract_category = u'sample'
    6464        self.app['products'].addProduct(product)
    6565        self.product_id = product.product_id
    6666        self.product = self.app['products'][self.product_id]
    6767
    68         application = createObject('waeup.SampleApplication')
    69         application.title = u'My Samle Application'
    70         application.product = product
    71         application.last_product_id = product.product_id
    72         self.customer['applications'].addApplication(application)
    73         self.application_id = application.application_id
    74         self.application = self.customer['applications'][self.application_id]
     68        contract = createObject('waeup.SampleContract')
     69        contract.title = u'My Samle Contract'
     70        contract.product = product
     71        contract.last_product_id = product.product_id
     72        self.customer['contracts'].addContract(contract)
     73        self.contract_id = contract.contract_id
     74        self.contract = self.customer['contracts'][self.contract_id]
    7575
    7676        document = createObject('waeup.CustomerSampleDocument')
     
    125125
    126126    def test_search_by_id(self):
    127         # We can find a certain application id
     127        # We can find a certain contract id
    128128        cat = queryUtility(ICatalog, name='documents_catalog')
    129129        results = cat.searchResults(document_id=(self.document_id,
     
    134134
    135135
    136 class ApplicationsCatalogTests(CatalogTestSetup):
     136class ContractsCatalogTests(CatalogTestSetup):
    137137
    138138    layer = FunctionalLayer
     
    140140    def test_get_catalog(self):
    141141        # We can get an customers catalog if we wish
    142         cat = queryUtility(ICatalog, name='applications_catalog')
     142        cat = queryUtility(ICatalog, name='contracts_catalog')
    143143        assert cat is not None
    144144
    145145    def test_search_by_id(self):
    146         # We can find a certain application id
    147         cat = queryUtility(ICatalog, name='applications_catalog')
    148         results = cat.searchResults(application_id=(self.application_id,
    149                                                 self.application_id))
     146        # We can find a certain contract id
     147        cat = queryUtility(ICatalog, name='contracts_catalog')
     148        results = cat.searchResults(contract_id=(self.contract_id,
     149                                                self.contract_id))
    150150        results = [x for x in results] # Turn results generator into list
    151151        assert len(results) == 1
    152         assert results[0] is self.customer['applications'][self.application_id]
     152        assert results[0] is self.customer['contracts'][self.contract_id]
    153153
    154154    def test_search_by_category(self):
    155155        # We can find a certain name
    156         cat = queryUtility(ICatalog, name='applications_catalog')
    157         results = cat.searchResults(application_category=('sample', 'sample'))
     156        cat = queryUtility(ICatalog, name='contracts_catalog')
     157        results = cat.searchResults(contract_category=('sample', 'sample'))
    158158        results = [x for x in results] # Turn results generator into list
    159159        assert len(results) == 1
    160         assert results[0] is self.customer['applications'][self.application_id]
     160        assert results[0] is self.customer['contracts'][self.contract_id]
    161161
    162162    def test_search_by_last_product_id(self):
    163163        # We can find a certain name
    164         cat = queryUtility(ICatalog, name='applications_catalog')
     164        cat = queryUtility(ICatalog, name='contracts_catalog')
    165165        results = cat.searchResults(last_product_id=('SAM', 'SAM'))
    166166        results = [x for x in results] # Turn results generator into list
    167167        assert len(results) == 1
    168         assert results[0] is self.customer['applications'][self.application_id]
     168        assert results[0] is self.customer['contracts'][self.contract_id]
    169169        assert results[0].product is self.product
    170170
    171171    def test_product_removal(self):
    172172        # This test does not only test catalog components, it also ensures
    173         # that the product attribute of an application is cleared
     173        # that the product attribute of an contract is cleared
    174174        # but the last_product_id is not.
    175175        del self.app['products'][self.product_id]
    176         self.assertTrue(self.application.product is None)
    177         self.assertEqual(self.application.last_product_id, 'SAM')
    178         cat = queryUtility(ICatalog, name='applications_catalog')
     176        self.assertTrue(self.contract.product is None)
     177        self.assertEqual(self.contract.last_product_id, 'SAM')
     178        cat = queryUtility(ICatalog, name='contracts_catalog')
    179179        results = cat.searchResults(last_product_id=('SAM', 'SAM'))
    180180        results = [x for x in results]
    181181        assert len(results) == 1
    182         assert results[0] is self.customer['applications'][self.application_id]
     182        assert results[0] is self.customer['contracts'][self.contract_id]
    183183        assert results[0].product is None
    184184        # Product removal is being logged in customers.log
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_contract.py

    r12096 r12097  
    1717##
    1818"""
    19 Tests for applications.
     19Tests for contracts.
    2020"""
    2121from zope.interface.verify import verifyClass, verifyObject
     
    2424    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
    2525from waeup.ikoba.customers.interfaces import (
    26     IApplicationsContainer, IApplication)
     26    IContractsContainer, IContract)
    2727from waeup.ikoba.interfaces import IObjectHistory
    28 from waeup.ikoba.customers.applications import (
    29     ApplicationsContainer, SampleApplication)
     28from waeup.ikoba.customers.contracts import (
     29    ContractsContainer, SampleContract)
    3030from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
    3131
    32 class ApplicationsContainerTestCase(FunctionalTestCase):
     32class ContractsContainerTestCase(FunctionalTestCase):
    3333
    3434    layer = FunctionalLayer
     
    3838        self.assertTrue(
    3939            verifyClass(
    40                 IApplicationsContainer, ApplicationsContainer)
     40                IContractsContainer, ContractsContainer)
    4141            )
    4242        self.assertTrue(
    4343            verifyObject(
    44                 IApplicationsContainer, ApplicationsContainer())
     44                IContractsContainer, ContractsContainer())
    4545            )
    4646        self.assertTrue(
    4747            verifyClass(
    48                 IApplication, SampleApplication)
     48                IContract, SampleContract)
    4949            )
    5050        self.assertTrue(
    5151            verifyObject(
    52                 IApplication, SampleApplication())
     52                IContract, SampleContract())
    5353            )
    5454        return
    5555
    56     def test_addApplication(self):
    57         container = ApplicationsContainer()
    58         application = createObject(u'waeup.SampleApplication')
    59         id = application.application_id
    60         container.addApplication(application)
    61         self.assertEqual(container[id], application)
    62         self.assertRaises(TypeError, container.addApplication, object())
    63         self.assertEqual(application.class_name, 'SampleApplication')
     56    def test_addContract(self):
     57        container = ContractsContainer()
     58        contract = createObject(u'waeup.SampleContract')
     59        id = contract.contract_id
     60        container.addContract(contract)
     61        self.assertEqual(container[id], contract)
     62        self.assertRaises(TypeError, container.addContract, object())
     63        self.assertEqual(contract.class_name, 'SampleContract')
    6464        self.assertEqual(id, 'a123')
    6565        return
    6666
    67     def test_application_workflow(self):
    68         application = createObject(u'waeup.SampleApplication')
    69         IWorkflowInfo(application).fireTransition('create')
    70         self.assertEqual(IWorkflowState(application).getState(), 'created')
    71         IWorkflowInfo(application).fireTransition('submit')
    72         self.assertEqual(IWorkflowState(application).getState(), 'submitted')
    73         IWorkflowInfo(application).fireTransition('approve')
    74         self.assertEqual(IWorkflowState(application).getState(), 'approved')
    75         IWorkflowInfo(application).fireTransition('expire')
    76         self.assertEqual(IWorkflowState(application).getState(), 'expired')
    77         IWorkflowInfo(application).fireTransition('reset4')
    78         self.assertEqual(IWorkflowState(application).getState(), 'created')
     67    def test_contract_workflow(self):
     68        contract = createObject(u'waeup.SampleContract')
     69        IWorkflowInfo(contract).fireTransition('create')
     70        self.assertEqual(IWorkflowState(contract).getState(), 'created')
     71        IWorkflowInfo(contract).fireTransition('submit')
     72        self.assertEqual(IWorkflowState(contract).getState(), 'submitted')
     73        IWorkflowInfo(contract).fireTransition('approve')
     74        self.assertEqual(IWorkflowState(contract).getState(), 'approved')
     75        IWorkflowInfo(contract).fireTransition('expire')
     76        self.assertEqual(IWorkflowState(contract).getState(), 'expired')
     77        IWorkflowInfo(contract).fireTransition('reset4')
     78        self.assertEqual(IWorkflowState(contract).getState(), 'created')
    7979        self.assertRaises(InvalidTransitionError,
    80             IWorkflowInfo(application).fireTransition, 'approve')
    81         IWorkflowInfo(application).fireTransition('submit')
    82         IWorkflowInfo(application).fireTransition('reset3')
    83         self.assertEqual(IWorkflowState(application).getState(), 'created')
     80            IWorkflowInfo(contract).fireTransition, 'approve')
     81        IWorkflowInfo(contract).fireTransition('submit')
     82        IWorkflowInfo(contract).fireTransition('reset3')
     83        self.assertEqual(IWorkflowState(contract).getState(), 'created')
    8484        return
    8585
    86     def test_application_history(self):
    87         doc = createObject(u'waeup.SampleApplication')
     86    def test_contract_history(self):
     87        doc = createObject(u'waeup.SampleContract')
    8888        IWorkflowInfo(doc).fireTransition('create')
    8989        messages = ' '.join(doc.history.messages)
    90         self.assertTrue('Application record created by system' in messages)
     90        self.assertTrue('Contract record created by system' in messages)
    9191        return
Note: See TracChangeset for help on using the changeset viewer.