Index: /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
===================================================================
--- /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py	(revision 12340)
+++ /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py	(revision 12341)
@@ -23,4 +23,5 @@
 import pytz
 import base64
+from decimal import Decimal
 from datetime import datetime, timedelta, date
 from StringIO import StringIO
@@ -52,4 +53,5 @@
 from waeup.ikoba.interfaces import VERIFIED
 from waeup.ikoba.browser.tests.test_pdf import samples_dir
+from waeup.ikoba.products.productoptions import ProductOption
 
 PH_LEN = 15911  # Length of placeholder file
@@ -104,4 +106,9 @@
         self.product.title = u'Our Sample Product'
         self.product.contract_category = u'sample'
+        prodoption = ProductOption()
+        prodoption.title = u'First option'
+        prodoption.fee = Decimal('99.9')
+        prodoption.currency = 'usd'
+        self.product.options = [prodoption,]
         self.app['products'].addProduct(self.product)
 
@@ -1154,4 +1161,5 @@
         # Managers can access the pages of customer contractsconter
         # and can perform actions
+        IWorkflowState(self.customer).setState(APPROVED)
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.customer_path)
@@ -1200,5 +1208,5 @@
             in logcontent)
         self.assertTrue(
-            'INFO - zope.mgr - customers.browser.ContractAddFormPage '
+            'INFO - zope.mgr - customers.browser.ContractAddPage '
             '- K1000000 - added: Sample Contract %s'
             % contract.contract_id in logcontent)
@@ -1210,5 +1218,5 @@
             in logcontent)
         self.assertTrue(
-            'INFO - zope.mgr - customers.browser.ContractsManageFormPage '
+            'INFO - zope.mgr - customers.browser.ContractsFormPage '
             '- K1000000 - removed: %s' % conid
             in logcontent)
@@ -1229,4 +1237,11 @@
             '...You logged in...', self.browser.contents)
         self.browser.getLink("Contracts").click()
+        # Customer is in wrong state
+        self.assertFalse('Add contract' in self.browser.contents)
+        self.browser.open(self.contracts_path + '/addcontract')
+        self.assertTrue('The requested form is locked' in self.browser.contents)
+        IWorkflowState(self.customer).setState(APPROVED)
+        self.browser.open(self.contracts_path)
+        # Now customer can add a contract
         self.browser.getControl("Add contract").click()
         self.browser.getControl(name="contype").value = ['SampleContract']
@@ -1235,11 +1250,6 @@
         conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
         contract = self.customer['contracts'][conid]
-        # Contract can be edited ...
-        self.browser.open(self.contracts_path + '/%s/edit' % conid)
-        #self.browser.getLink("Edit").click()
-        self.assertTrue('The requested form is locked' in self.browser.contents)
-        # Customer is in wrong state
-        IWorkflowState(self.customer).setState(APPROVED)
-        self.browser.open(self.contracts_path + '/%s/edit' % conid)
+        self.assertEqual(
+            self.browser.url, self.contracts_path + '/%s/selectproduct' % conid)
         # SAM is in the correct contract_category ...
         self.assertTrue('<option value="SAM">' in self.browser.contents)
@@ -1249,6 +1259,9 @@
         self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
         self.browser.getControl(name="form.product_object").value = ['SAM']
+        self.browser.getControl("Save and proceed").click()
+        self.assertEqual(
+            self.browser.url, self.contracts_path + '/%s/edit' % conid)
+        # Document is a required field on edit form page.
         self.browser.getControl("Save").click()
-        # Document is a required field on edit form page.
         self.assertTrue('Document: <span class="error">Required input is missing.</span>'
             in self.browser.contents)
@@ -1257,5 +1270,4 @@
         IWorkflowState(self.document).setState(SUBMITTED)
         self.browser.open(self.contracts_path + '/%s/edit' % conid)
-        self.browser.getControl(name="form.product_object").value = ['SAM']
         self.browser.getControl(name="form.document_object").value = ['DOC1']
         self.browser.getControl("Save").click()
@@ -1270,5 +1282,27 @@
         self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
         self.assertTrue('Form has been saved.' in self.browser.contents)
+        # So far we have not yet set product options.
+        # Unfortunately, we can't set them in test browser
+        prodoption = ProductOption()
+        prodoption.title = u'Any product option'
+        prodoption.fee = Decimal('88.8')
+        prodoption.currency = 'eur'
+        contract.product_options = [prodoption,]
+        self.browser.open(self.contracts_path + '/%s/edit' % conid)
+        # We can see both the stored and the recent product options
+        # from the chosen product.
+        self.assertTrue('<option selected="selected" value="Any product option">'
+                        'Any product option @ 88.8 eur</option>'
+                        in self.browser.contents)
+        self.assertTrue('<option value="First option">First option '
+                        '@ 99.9 usd</option>' in self.browser.contents)
+        # In test browser we can at least replace the option
+        self.browser.getControl(
+            name="form.product_options.0.").value = ['First option']
+        self.assertEqual(contract.product_options[0].title, 'Any product option')
+        self.browser.getControl("Save").click()
+        self.assertEqual(contract.product_options[0].title, 'First option')
         self.browser.getLink("View").click()
+        self.assertTrue('<span>First option @ 99.9 usd</span>' in self.browser.contents)
         self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
         # An href attribute is referring to the document and product objects
