Index: /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_browser.py
===================================================================
--- /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_browser.py	(revision 12691)
+++ /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_browser.py	(revision 12692)
@@ -1,4 +1,4 @@
 ## $Id$
-## 
+##
 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
 ## This program is free software; you can redistribute it and/or modify
@@ -6,10 +6,10 @@
 ## the Free Software Foundation; either version 2 of the License, or
 ## (at your option) any later version.
-## 
+##
 ## This program is distributed in the hope that it will be useful,
 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ## GNU General Public License for more details.
-## 
+##
 ## You should have received a copy of the GNU General Public License
 ## along with this program; if not, write to the Free Software
@@ -62,4 +62,5 @@
 SAMPLE_PDF = os.path.join(os.path.dirname(__file__), 'test_pdf.pdf')
 
+
 def lookup_submit_value(name, value, browser):
     """Find a button with a certain value."""
@@ -72,4 +73,5 @@
             break
     return None
+
 
 class CustomersFullSetup(FunctionalTestCase):
@@ -119,5 +121,5 @@
         prodoption.fee = Decimal('99.9')
         prodoption.currency = 'USD'
-        self.product.options = [prodoption,]
+        self.product.options = [prodoption, ]
         self.app['products'].addProduct(self.product)
 
@@ -138,10 +140,12 @@
         self.document.document_id = u'DOC1'
         self.assertRaises(
-            NotIdValue, setattr, self.document, 'document_id', u'id with spaces')
+            NotIdValue, setattr, self.document, 'document_id',
+            u'id with spaces')
         self.customer['documents'].addDocument(self.document)
         self.contract = createObject(self._contract_factory)
         self.contract.contract_id = u'CON1'
         self.assertRaises(
-            NotIdValue, setattr, self.contract, 'contract_id', u'id with spaces')
+            NotIdValue, setattr, self.contract, 'contract_id',
+            u'id with spaces')
         self.customer['contracts'].addContract(self.contract)
 
@@ -299,7 +303,7 @@
         return
 
+
 class OfficerUITests(CustomersFullSetup):
     # Tests for Customer class views and pages
-
 
     def setup_logging(self):
@@ -331,12 +335,14 @@
         self.browser.getLink("Logout").click()
         self.assertTrue('You have been logged out' in self.browser.contents)
-        # But we are still logged in since we've used basic authentication here.
-        # Wikipedia says: Existing browsers retain authentication information
-        # until the tab or browser is closed or the user clears the history.
-        # HTTP does not provide a method for a server to direct clients to
-        # discard these cached credentials. This means that there is no
-        # effective way for a server to "log out" the user without closing
-        # the browser. This is a significant defect that requires browser
-        # manufacturers to support a "logout" user interface element ...
+        # But we are still logged in since we've used basic
+        # authentication here.  Wikipedia says: Existing browsers
+        # retain authentication information until the tab or browser
+        # is closed or the user clears the history.  HTTP does not
+        # provide a method for a server to direct clients to discard
+        # these cached credentials. This means that there is no
+        # effective way for a server to "log out" the user without
+        # closing the browser. This is a significant defect that
+        # requires browser manufacturers to support a "logout" user
+        # interface element ...
         self.assertTrue('Manager' in self.browser.contents)
 
@@ -378,5 +384,6 @@
         self.browser.open(self.customer_path)
         self.browser.getLink("Send email").click()
-        self.browser.getControl(name="form.subject").value = 'Important subject'
+        self.browser.getControl(
+            name="form.subject").value = 'Important subject'
         self.browser.getControl(name="form.body").value = 'Hello!'
         self.browser.getControl("Send message now").click()
@@ -409,5 +416,4 @@
         self.browser.getControl('Delete').click()
         self.assertTrue('passport.jpg deleted' in self.browser.contents)
-
 
     def test_manage_workflow_send_transition_information(self):
@@ -459,5 +465,6 @@
         self.browser.getControl("Apply").click()
         self.browser.open(self.trigtrans_path)
-        self.browser.getControl(name="transition").value = ['approve_provisionally']
+        self.browser.getControl(name="transition").value = [
+            'approve_provisionally']
         self.browser.getControl("Apply").click()
         self.browser.open(self.trigtrans_path)
@@ -499,5 +506,6 @@
         self.browser.getControl('Perform import').click()
         self.assertTrue('Processing of 1 rows failed' in self.browser.contents)
-        self.assertTrue('Successfully processed 2 rows' in self.browser.contents)
+        self.assertTrue(
+            'Successfully processed 2 rows' in self.browser.contents)
         self.assertTrue('Batch processing finished' in self.browser.contents)
 
@@ -535,16 +543,19 @@
         self.browser.getLink("History").click()
         self.assertTrue(
-            'Customer account deactivated by Manager<br />' in self.browser.contents)
-        self.assertTrue(
-            'Customer account activated by Manager<br />' in self.browser.contents)
+            'Customer account deactivated by Manager<br />'
+            in self.browser.contents)
+        self.assertTrue(
+            'Customer account activated by Manager<br />'
+            in self.browser.contents)
         # ... and actions have been logged.
         logfile = os.path.join(
             self.app['datacenter'].storage, 'logs', 'customers.log')
         logcontent = open(logfile).read()
-        self.assertTrue('zope.mgr - customers.browser.CustomerDeactivatePage - '
-                        'K1000000 - account deactivated' in logcontent)
-        self.assertTrue('zope.mgr - customers.browser.CustomerActivatePage - '
-                        'K1000000 - account activated' in logcontent)
-
+        self.assertTrue(
+            'zope.mgr - customers.browser.CustomerDeactivatePage - '
+            'K1000000 - account deactivated' in logcontent)
+        self.assertTrue(
+            'zope.mgr - customers.browser.CustomerActivatePage - '
+            'K1000000 - account activated' in logcontent)
 
     def test_login_as_customer(self):
@@ -554,5 +565,6 @@
         self.app['users']['mrofficer'].title = 'Harry Actor'
         prmglobal = IPrincipalRoleManager(self.app)
-        prmglobal.assignRoleToPrincipal('waeup.CustomerImpersonator', 'mrofficer')
+        prmglobal.assignRoleToPrincipal(
+            'waeup.CustomerImpersonator', 'mrofficer')
         prmglobal.assignRoleToPrincipal('waeup.CustomersManager', 'mrofficer')
         self.assertEqual(self.customer.state, 'created')
@@ -574,5 +586,6 @@
         # We are logged in as customer and can see the 'My Data' tab
         self.assertMatches(
-            '...<a href="#" class="dropdown-toggle" data-toggle="dropdown">...',
+            '...<a href="#" class="dropdown-toggle"'
+            ' data-toggle="dropdown">...',
             self.browser.contents)
         self.assertMatches(
@@ -724,5 +737,6 @@
         self.assertMatches(
             '...<div class="alert alert-warning">'
-            'Your account has been deactivated.</div>...', self.browser.contents)
+            'Your account has been deactivated.</div>...',
+            self.browser.contents)
         # If suspended_comment is set this message will be flashed instead
         self.customer.suspended_comment = u'Aetsch baetsch!'
@@ -778,4 +792,5 @@
         self.assertTrue('An email with' in self.browser.contents)
 
+
 class CustomerRegistrationTests(CustomersFullSetup):
     # Tests for customer registration
@@ -823,10 +838,11 @@
             cat.searchResults(
             email=('new@yy.zz', 'new@yy.zz')))
-        self.assertEqual(self.customer,results[0])
+        self.assertEqual(self.customer, results[0])
         logfile = os.path.join(
             self.app['datacenter'].storage, 'logs', 'main.log')
         logcontent = open(logfile).read()
-        self.assertTrue('zope.anybody - customers.browser.CustomerRequestPasswordPage - '
-                        '123 (K1000000) - new@yy.zz' in logcontent)
+        self.assertTrue(
+            'zope.anybody - customers.browser.CustomerRequestPasswordPage - '
+            '123 (K1000000) - new@yy.zz' in logcontent)
         return
 
@@ -841,5 +857,6 @@
         self.browser.getControl(name="form.email").value = 'newcustomer@xx.zz'
         self.browser.getControl("Send login credentials").click()
-        self.assertTrue('Your request was successful.' in self.browser.contents)
+        self.assertTrue(
+            'Your request was successful.' in self.browser.contents)
         # Customer can be found in the catalog via the email address
         cat = queryUtility(ICatalog, name='customers_catalog')
@@ -849,11 +866,14 @@
         self.assertEqual(self.app['customers']['K1000001'], results[0])
         self.assertEqual(self.app['customers']['K1000001'].firstname, 'Ruben')
-        self.assertEqual(self.app['customers']['K1000001'].lastname, 'Gonzales')
+        self.assertEqual(
+            self.app['customers']['K1000001'].lastname, 'Gonzales')
         logfile = os.path.join(
             self.app['datacenter'].storage, 'logs', 'main.log')
         logcontent = open(logfile).read()
-        self.assertTrue('zope.anybody - customers.browser.CustomerCreateAccountPage - '
-                        'K1000001 - newcustomer@xx.zz' in logcontent)
+        self.assertTrue(
+            'zope.anybody - customers.browser.CustomerCreateAccountPage - '
+            'K1000001 - newcustomer@xx.zz' in logcontent)
         return
+
 
 class CustomerDataExportTests(CustomersFullSetup, FunctionalAsyncTestCase):
@@ -929,5 +949,6 @@
         self.browser.getControl("Add document").click()
         self.assertTrue('PDF Document added.' in self.browser.contents)
-        docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
+        docid = [i for i in self.customer['documents'].keys()
+                 if len(i) > 10][0]
         document = self.customer['documents'][docid]
 
@@ -950,5 +971,6 @@
         self.browser.getControl(name="transition").value = ['verify']
         self.browser.getControl("Apply").click()
-        self.assertTrue('Customer has not yet been approved' in self.browser.contents)
+        self.assertTrue(
+            'Customer has not yet been approved' in self.browser.contents)
         IWorkflowState(self.customer).setState(APPROVED)
         # Document can only be verified if files have been uploaded before
@@ -958,5 +980,6 @@
         self.assertTrue('No file uploaded' in self.browser.contents)
         self.assertEqual(document.state, 'submitted')
-        # We set state here manually (verification is tested in test_verify_document)
+        # We set state here manually (verification is tested in
+        # test_verify_document)
         IWorkflowState(document).setState(VERIFIED)
 
@@ -964,5 +987,6 @@
         self.browser.open(self.documents_path + '/' + docid + '/index')
         self.assertFalse(
-            'href="http://localhost/app/customers/K1000000/documents/%s/manage"'
+            'href="http://localhost/app/customers/K1000000/'
+            'documents/%s/manage"'
             % docid in self.browser.contents)
         self.browser.open(self.documents_path + '/' + docid + '/manage')
@@ -1012,13 +1036,16 @@
         self.browser.getLink("Documents").click()
         self.browser.getControl("Add document").click()
-        self.assertTrue('The requested form is locked' in self.browser.contents)
+        self.assertTrue(
+            'The requested form is locked' in self.browser.contents)
         # Customer is in wrong state
         IWorkflowState(self.customer).setState(APPROVED)
         self.browser.getControl("Add document").click()
-        self.browser.getControl(name="doctype").value = ['CustomerSampleDocument']
+        self.browser.getControl(name="doctype").value = [
+            'CustomerSampleDocument']
         self.browser.getControl(name="form.title").value = 'My Sample Document'
         self.browser.getControl("Add document").click()
         self.assertTrue('Sample Document added.' in self.browser.contents)
-        docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
+        docid = [i for i in self.customer['documents'].keys()
+                 if len(i) > 10][0]
         document = self.customer['documents'][docid]
         self.browser.getControl(name="form.title").value = 'My second doc'
@@ -1038,5 +1065,6 @@
             name='upload_samplescaneditupload').click()
         self.assertTrue(
-            'href="http://localhost/app/customers/K1000000/documents/%s/sample"'
+            'href="http://localhost/app/customers/K1000000/'
+            'documents/%s/sample"'
             % docid in self.browser.contents)
         # Customer can submit the form. The form is also saved.
@@ -1045,8 +1073,11 @@
         self.assertEqual(document.title, 'My third doc')
         self.assertEqual(document.state, 'submitted')
-        self.assertTrue('Document State: submitted for verification' in self.browser.contents)
+        self.assertTrue(
+            'Document State: submitted for verification'
+            in self.browser.contents)
         # Customer can't edit the document once it has been submitted
         self.browser.open(self.documents_path + '/%s/edit' % docid)
-        self.assertTrue('The requested form is locked' in self.browser.contents)
+        self.assertTrue(
+            'The requested form is locked' in self.browser.contents)
 
     def test_manage_upload_sample_file(self):
@@ -1055,5 +1086,5 @@
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.customer_path + '/documents/DOC1/manage')
-        # Create a pseudo image file and select it to be uploaded 
+        # Create a pseudo image file and select it to be uploaded
         image = open(SAMPLE_IMAGE, 'rb')
         ctrl = self.browser.getControl(name='samplescanmanageupload')
@@ -1061,7 +1092,8 @@
         file_ctrl.add_file(image, filename='my_sample_scan.jpg')
         # The Save action does not upload files
-        self.browser.getControl("Save").click() # submit form
+        self.browser.getControl("Save").click()  # submit form
         self.assertFalse(
-            'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"'
+            'href="http://localhost/app/customers/K1000000/'
+            'documents/DOC1/sample"'
             in self.browser.contents)
         # ... but the correct upload submit button does
@@ -1073,5 +1105,6 @@
             name='upload_samplescanmanageupload').click()
         self.assertTrue(
-            'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"'
+            'href="http://localhost/app/customers/K1000000/'
+            'documents/DOC1/sample"'
             in self.browser.contents)
         # Browsing the link shows a real image
@@ -1098,5 +1131,5 @@
             'Uploaded file is too big' in self.browser.contents)
         # We do not rely on filename extensions given by uploaders
-        image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
+        image = open(SAMPLE_IMAGE, 'rb')  # a jpg-file
         ctrl = self.browser.getControl(name='samplescanmanageupload')
         file_ctrl = ctrl.mech_control
@@ -1152,5 +1185,6 @@
         self.browser.getControl(name="form.title").value = 'My PDF Document'
         self.browser.getControl("Add document").click()
-        docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
+        docid = [
+            i for i in self.customer['documents'].keys() if len(i) > 10][0]
         self.browser.open(self.documents_path + '/%s/manage' % docid)
         # Create a pseudo image file and select it to be uploaded
@@ -1177,5 +1211,6 @@
             name='upload_pdfscanmanageupload').click()
         self.assertTrue(
-            'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">%s.pdf</a>'
+            'href="http://localhost/app/customers/K1000000/'
+            'documents/%s/sample.pdf">%s.pdf</a>'
             % (docid, docid[:9]) in self.browser.contents)
         # Browsing the link shows a real pdf
@@ -1194,5 +1229,6 @@
         self.browser.getLink("Download documents overview").click()
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
+        self.assertEqual(
+            self.browser.headers['Content-Type'], 'application/pdf')
         path = os.path.join(samples_dir(), 'documents_overview_slip.pdf')
         open(path, 'wb').write(self.browser.contents)
@@ -1200,5 +1236,6 @@
         # Officers can open document slips which shows a thumbnail of
         # the jpeg file attached.
-        file_id = IFileStoreNameChooser(self.document).chooseName(attr='sample.jpg')
+        file_id = IFileStoreNameChooser(self.document).chooseName(
+            attr='sample.jpg')
         fs = ExtFileStore(root=self.dc_root)
         jpegfile = open(SAMPLE_IMAGE, 'rb')
@@ -1207,5 +1244,6 @@
         self.browser.getLink("Download document slip").click()
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
+        self.assertEqual(
+            self.browser.headers['Content-Type'], 'application/pdf')
         path = os.path.join(samples_dir(), 'document_slip.pdf')
         open(path, 'wb').write(self.browser.contents)
@@ -1216,13 +1254,16 @@
         self.customer['documents'].addDocument(pdfdocument)
         # Add pdf file
-        file_id = IFileStoreNameChooser(pdfdocument).chooseName(attr='sample.pdf')
+        file_id = IFileStoreNameChooser(pdfdocument).chooseName(
+            attr='sample.pdf')
         fs = ExtFileStore(root=self.dc_root)
         pdffile = open(SAMPLE_PDF, 'rb')
         fs.createFile(file_id, pdffile)
-        docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
+        docid = [i for i in self.customer['documents'].keys()
+                 if len(i) > 10][0]
         self.browser.open(self.customer_path + '/documents/' + docid)
         self.browser.getLink("Download document slip").click()
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
+        self.assertEqual(
+            self.browser.headers['Content-Type'], 'application/pdf')
         path = os.path.join(samples_dir(), 'pdfdocument_slip.pdf')
         open(path, 'wb').write(self.browser.contents)
@@ -1232,13 +1273,18 @@
         # A proper file name chooser is registered for customer documents.
         # This is not a UI test. It's just a functional test.
-        file_id = IFileStoreNameChooser(self.document).chooseName(attr='sample')
+        file_id = IFileStoreNameChooser(self.document).chooseName(
+            attr='sample')
         fs = ExtFileStore(root=self.dc_root)
         fs.createFile(file_id, StringIO('my sample 1'))
         result = fs.getFileByContext(self.document, attr='sample')
-        self.assertEqual(file_id, '__file-customerdocument__01000/K1000000/sample_DOC1_K1000000')
+        self.assertEqual(
+            file_id, '__file-customerdocument__01000/'
+            'K1000000/sample_DOC1_K1000000')
         self.assertEqual(result.read(), 'my sample 1')
-        self.assertEqual(self.document.connected_files[0][1].read(), 'my sample 1')
+        self.assertEqual(
+            self.document.connected_files[0][1].read(), 'my sample 1')
         self.document.setMD5()
-        self.assertEqual(self.document.sample_md5, 'a406995ee8eb6772bacf51aa4b0caa24')
+        self.assertEqual(
+            self.document.sample_md5, 'a406995ee8eb6772bacf51aa4b0caa24')
         return
 
@@ -1261,12 +1307,15 @@
         self.browser.getControl("Add contract").click()
         self.assertTrue('Sample Contract added.' in self.browser.contents)
-        conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
+        conid = [i for i in self.customer['contracts'].keys()
+                 if len(i) > 10][0]
         contract = self.customer['contracts'][conid]
         self.assertEqual(
-            self.browser.url, self.contracts_path + '/%s/selectproduct' % conid)
+            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)
         # So far last_product_id is None.
-        self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
+        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()
@@ -1274,5 +1323,6 @@
             self.browser.url, self.contracts_path + '/%s/manage' % conid)
         self.browser.getLink("View").click()
-        self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
+        self.assertEqual(
+            self.browser.url, self.contracts_path + '/%s/index' % conid)
         self.assertEqual(contract.tc_dict, {'en': u'Hello world'})
 
@@ -1342,5 +1392,6 @@
         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)
+        self.assertTrue(
+            'The requested form is locked' in self.browser.contents)
         IWorkflowState(self.customer).setState(APPROVED)
         self.browser.open(self.contracts_path)
@@ -1350,8 +1401,10 @@
         self.browser.getControl("Add contract").click()
         self.assertTrue('Sample Contract added.' in self.browser.contents)
-        conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
+        conid = [i for i in self.customer['contracts'].keys()
+                 if len(i) > 10][0]
         contract = self.customer['contracts'][conid]
         self.assertEqual(
-            self.browser.url, self.contracts_path + '/%s/selectproduct' % conid)
+            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)
@@ -1359,5 +1412,6 @@
         self.assertFalse('<option value="LIC">' in self.browser.contents)
         # So far last_product_id is None.
-        self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
+        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()
@@ -1366,5 +1420,6 @@
         # Document is a required field on edit form page.
         self.browser.getControl("Save").click()
-        self.assertTrue('Document: <span class="error">Required input is missing.</span>'
+        self.assertTrue(
+            'Document: <span class="error">Required input is missing.</span>'
             in self.browser.contents)
         # But our document can't be selected because it's not submitted
@@ -1376,5 +1431,6 @@
         # After saving the form, last_product_id and other attributes are set
         self.assertTrue('Form has been saved.' in self.browser.contents)
-        self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
+        self.assertEqual(
+            self.customer['contracts'][conid].last_product_id, 'SAM')
         self.assertEqual(contract.title, 'Our Sample Product')
         self.assertEqual(contract.product_object, self.product)
@@ -1382,5 +1438,6 @@
         # Saving the form again does not unset last_product_id
         self.browser.getControl("Save").click()
-        self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
+        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.
@@ -1390,11 +1447,12 @@
         prodoption.fee = Decimal('88.8')
         prodoption.currency = 'EUR'
-        contract.product_options = [prodoption,]
+        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 Euro</option>'
-                        in self.browser.contents)
+        self.assertTrue(
+            '<option selected="selected" value="Any product option">'
+            'Any product option @ 88.8 Euro</option>'
+            in self.browser.contents)
         self.assertTrue('<option value="First option">First option '
                         '@ 99.9 US Dollar</option>' in self.browser.contents)
@@ -1402,15 +1460,20 @@
         self.browser.getControl(
             name="form.product_options.0.").value = ['First option']
-        self.assertEqual(contract.product_options[0].title, 'Any product 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 US Dollar</span>' in self.browser.contents)
-        self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
+        self.assertTrue(
+            '<span>First option @ 99.9 US Dollar</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
         self.assertTrue('<a href="http://localhost/app/products/SAM">SAM -'
             in self.browser.contents)
         self.assertTrue(
-            '<a href="http://localhost/app/customers/K1000000/documents/DOC1">DOC1 -'
+            '<a href="http://localhost/app/customers/K1000000/'
+            'documents/DOC1">DOC1 -'
             in self.browser.contents)
         # Customer can submit the form if confirmation box is ticket.
@@ -1418,5 +1481,7 @@
         self.browser.getLink("Edit").click()
         self.browser.getControl("Proceed to checkout").click()
-        self.assertTrue('confirm your acceptance of these by ticking' in self.browser.contents)
+        self.assertTrue(
+            'confirm your acceptance of these by ticking'
+            in self.browser.contents)
         self.assertEqual(contract.state, 'created')
         self.browser.getControl(name="confirm_tc").value = True
@@ -1429,5 +1494,6 @@
         # Customer can't edit the contract once it has been submitted
         self.browser.open(self.contracts_path + '/%s/edit' % conid)
-        self.assertTrue('The requested form is locked' in self.browser.contents)
+        self.assertTrue(
+            'The requested form is locked' in self.browser.contents)
 
     def test_view_slips(self):
@@ -1437,5 +1503,6 @@
         self.browser.getLink("Download contracts overview").click()
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
+        self.assertEqual(
+            self.browser.headers['Content-Type'], 'application/pdf')
         path = os.path.join(samples_dir(), 'contracts_overview_slip.pdf')
         open(path, 'wb').write(self.browser.contents)
@@ -1453,5 +1520,6 @@
         self.browser.getLink("Download contract slip").click()
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
-        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
+        self.assertEqual(
+            self.browser.headers['Content-Type'], 'application/pdf')
         path = os.path.join(samples_dir(), 'contract_slip.pdf')
         open(path, 'wb').write(self.browser.contents)
@@ -1488,5 +1556,6 @@
         # InvalidTransitionError is catched
         self.assertTrue(
-            '<div class="alert alert-warning">Attached documents must be verified first.</div>'
+            '<div class="alert alert-warning">Attached documents '
+            'must be verified first.</div>'
             in self.browser.contents)
         self.browser.open(self.contracts_path + '/CON1/trigtrans')
@@ -1501,5 +1570,5 @@
         prodoption.fee = Decimal('88.8')
         prodoption.currency = 'EUR'
-        contract.product_options = [prodoption,]
+        contract.product_options = [prodoption, ]
 
     def prepare_payment_select(self):
