Ignore:
Timestamp:
1 Dec 2014, 09:59:14 (10 years ago)
Author:
Henrik Bettermann
Message:

Add sample contract interfaces with additional document field. Use these interfaces in form pages.

File:
1 edited

Legend:

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

    r12098 r12103  
    4040from waeup.ikoba.customers.interfaces import ICustomersUtils
    4141from waeup.ikoba.customers.customer import Customer
    42 from waeup.ikoba.interfaces import IUserAccount, IJobManager, APPROVED
     42from waeup.ikoba.interfaces import (
     43    IUserAccount, IJobManager, APPROVED, SUBMITTED)
    4344from waeup.ikoba.authentication import LocalRoleSetEvent
    4445from waeup.ikoba.tests.test_async import FunctionalAsyncTestCase
     
    111112        self.customer_id = customer.customer_id
    112113        self.customer = self.app['customers'][self.customer_id]
    113         document = createObject('waeup.CustomerSampleDocument')
    114         document.title = u'My first document'
    115         self.customer['documents'].addDocument(document)
    116         contract = createObject('waeup.SampleContract')
    117         contract.title = u'My first contract'
    118         self.customer['contracts'].addContract(contract)
     114        self.document = createObject('waeup.CustomerSampleDocument')
     115        self.document.title = u'My first document'
     116        self.customer['documents'].addDocument(self.document)
     117        self.contract = createObject('waeup.SampleContract')
     118        self.contract.title = u'My first contract'
     119        self.customer['contracts'].addContract(self.contract)
    119120
    120121        # Set password
     
    10741075        self.browser.getLink("Manage").click()
    10751076        self.browser.getControl(name="form.product").value = ['SAM']
    1076         self.browser.getControl(name="form.title").value = 'My second app'
     1077        self.browser.getControl(name="form.title").value = 'My second contract'
    10771078        self.browser.getControl("Save").click()
    10781079        self.assertTrue('Form has been saved.' in self.browser.contents)
     
    11401141        IWorkflowState(self.customer).setState(APPROVED)
    11411142        self.browser.open(self.contracts_path + '/c102/edit')
    1142         self.browser.getControl(name="form.title").value = 'My second app'
     1143        self.browser.getControl(name="form.title").value = 'My second contract'
    11431144        # SAM is in the correct contract_category ...
    11441145        self.assertTrue('<option value="SAM">' in self.browser.contents)
     
    11491150        self.browser.getControl(name="form.product").value = ['SAM']
    11501151        self.browser.getControl("Save").click()
    1151         # After saving the form, last_product_id is set.
     1152        # Document is a required field on edit form page.
     1153        self.assertTrue('Document: <span class="error">Required input is missing.</span>'
     1154            in self.browser.contents)
     1155        # But our document can't be selected because it's not submitted
     1156        self.assertFalse('My first document' in self.browser.contents)
     1157        IWorkflowState(self.document).setState(SUBMITTED)
     1158        self.browser.open(self.contracts_path + '/c102/edit')
     1159        self.browser.getControl(name="form.product").value = ['SAM']
     1160        self.browser.getControl(name="form.document").value = ['d101']
     1161        self.browser.getControl(name="form.title").value = 'My second contract'
     1162        self.browser.getControl("Save").click()
     1163        # After saving the form, last_product_id and other attributes are set
     1164        self.assertTrue('Form has been saved.' in self.browser.contents)
    11521165        self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM')
    1153         self.assertTrue('Form has been saved.' in self.browser.contents)
     1166        self.assertEqual(contract.title, 'My second contract')
     1167        self.assertEqual(contract.product, self.product)
     1168        self.assertEqual(contract.document, self.document)
    11541169        # Saving the form again does not unset last_product_id
    1155         self.assertEqual(contract.title, 'My second app')
     1170        self.browser.getControl(name="form.title").value = 'My third contract'
    11561171        self.browser.getControl("Save").click()
    11571172        self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM')
     
    11611176        # Customer can submit the form. The form is also saved.
    11621177        self.browser.getLink("Edit").click()
    1163         self.browser.getControl(name="form.title").value = 'My third app'
     1178        self.browser.getControl(name="form.title").value = 'My fourth contract'
    11641179        self.browser.getControl("Apply now").click()
    1165         self.assertEqual(contract.title, 'My third app')
     1180        self.assertEqual(contract.title, 'My fourth contract')
    11661181        self.assertEqual(contract.state, 'submitted')
    11671182        self.assertTrue('Contract State: submitted for approval' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.