Ignore:
Timestamp:
8 Mar 2015, 19:40:47 (10 years ago)
Author:
uli
Message:

pep8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_browser.py

    r12691 r12692  
    11## $Id$
    2 ## 
     2##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
    44## This program is free software; you can redistribute it and/or modify
     
    66## the Free Software Foundation; either version 2 of the License, or
    77## (at your option) any later version.
    8 ## 
     8##
    99## This program is distributed in the hope that it will be useful,
    1010## but WITHOUT ANY WARRANTY; without even the implied warranty of
    1111## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1212## GNU General Public License for more details.
    13 ## 
     13##
    1414## You should have received a copy of the GNU General Public License
    1515## along with this program; if not, write to the Free Software
     
    6262SAMPLE_PDF = os.path.join(os.path.dirname(__file__), 'test_pdf.pdf')
    6363
     64
    6465def lookup_submit_value(name, value, browser):
    6566    """Find a button with a certain value."""
     
    7273            break
    7374    return None
     75
    7476
    7577class CustomersFullSetup(FunctionalTestCase):
     
    119121        prodoption.fee = Decimal('99.9')
    120122        prodoption.currency = 'USD'
    121         self.product.options = [prodoption,]
     123        self.product.options = [prodoption, ]
    122124        self.app['products'].addProduct(self.product)
    123125
     
    138140        self.document.document_id = u'DOC1'
    139141        self.assertRaises(
    140             NotIdValue, setattr, self.document, 'document_id', u'id with spaces')
     142            NotIdValue, setattr, self.document, 'document_id',
     143            u'id with spaces')
    141144        self.customer['documents'].addDocument(self.document)
    142145        self.contract = createObject(self._contract_factory)
    143146        self.contract.contract_id = u'CON1'
    144147        self.assertRaises(
    145             NotIdValue, setattr, self.contract, 'contract_id', u'id with spaces')
     148            NotIdValue, setattr, self.contract, 'contract_id',
     149            u'id with spaces')
    146150        self.customer['contracts'].addContract(self.contract)
    147151
     
    299303        return
    300304
     305
    301306class OfficerUITests(CustomersFullSetup):
    302307    # Tests for Customer class views and pages
    303 
    304308
    305309    def setup_logging(self):
     
    331335        self.browser.getLink("Logout").click()
    332336        self.assertTrue('You have been logged out' in self.browser.contents)
    333         # But we are still logged in since we've used basic authentication here.
    334         # Wikipedia says: Existing browsers retain authentication information
    335         # until the tab or browser is closed or the user clears the history.
    336         # HTTP does not provide a method for a server to direct clients to
    337         # discard these cached credentials. This means that there is no
    338         # effective way for a server to "log out" the user without closing
    339         # the browser. This is a significant defect that requires browser
    340         # manufacturers to support a "logout" user interface element ...
     337        # But we are still logged in since we've used basic
     338        # authentication here.  Wikipedia says: Existing browsers
     339        # retain authentication information until the tab or browser
     340        # is closed or the user clears the history.  HTTP does not
     341        # provide a method for a server to direct clients to discard
     342        # these cached credentials. This means that there is no
     343        # effective way for a server to "log out" the user without
     344        # closing the browser. This is a significant defect that
     345        # requires browser manufacturers to support a "logout" user
     346        # interface element ...
    341347        self.assertTrue('Manager' in self.browser.contents)
    342348
     
    378384        self.browser.open(self.customer_path)
    379385        self.browser.getLink("Send email").click()
    380         self.browser.getControl(name="form.subject").value = 'Important subject'
     386        self.browser.getControl(
     387            name="form.subject").value = 'Important subject'
    381388        self.browser.getControl(name="form.body").value = 'Hello!'
    382389        self.browser.getControl("Send message now").click()
     
    409416        self.browser.getControl('Delete').click()
    410417        self.assertTrue('passport.jpg deleted' in self.browser.contents)
    411 
    412418
    413419    def test_manage_workflow_send_transition_information(self):
     
    459465        self.browser.getControl("Apply").click()
    460466        self.browser.open(self.trigtrans_path)
    461         self.browser.getControl(name="transition").value = ['approve_provisionally']
     467        self.browser.getControl(name="transition").value = [
     468            'approve_provisionally']
    462469        self.browser.getControl("Apply").click()
    463470        self.browser.open(self.trigtrans_path)
     
    499506        self.browser.getControl('Perform import').click()
    500507        self.assertTrue('Processing of 1 rows failed' in self.browser.contents)
    501         self.assertTrue('Successfully processed 2 rows' in self.browser.contents)
     508        self.assertTrue(
     509            'Successfully processed 2 rows' in self.browser.contents)
    502510        self.assertTrue('Batch processing finished' in self.browser.contents)
    503511
     
    535543        self.browser.getLink("History").click()
    536544        self.assertTrue(
    537             'Customer account deactivated by Manager<br />' in self.browser.contents)
    538         self.assertTrue(
    539             'Customer account activated by Manager<br />' in self.browser.contents)
     545            'Customer account deactivated by Manager<br />'
     546            in self.browser.contents)
     547        self.assertTrue(
     548            'Customer account activated by Manager<br />'
     549            in self.browser.contents)
    540550        # ... and actions have been logged.
    541551        logfile = os.path.join(
    542552            self.app['datacenter'].storage, 'logs', 'customers.log')
    543553        logcontent = open(logfile).read()
    544         self.assertTrue('zope.mgr - customers.browser.CustomerDeactivatePage - '
    545                         'K1000000 - account deactivated' in logcontent)
    546         self.assertTrue('zope.mgr - customers.browser.CustomerActivatePage - '
    547                         'K1000000 - account activated' in logcontent)
    548 
     554        self.assertTrue(
     555            'zope.mgr - customers.browser.CustomerDeactivatePage - '
     556            'K1000000 - account deactivated' in logcontent)
     557        self.assertTrue(
     558            'zope.mgr - customers.browser.CustomerActivatePage - '
     559            'K1000000 - account activated' in logcontent)
    549560
    550561    def test_login_as_customer(self):
     
    554565        self.app['users']['mrofficer'].title = 'Harry Actor'
    555566        prmglobal = IPrincipalRoleManager(self.app)
    556         prmglobal.assignRoleToPrincipal('waeup.CustomerImpersonator', 'mrofficer')
     567        prmglobal.assignRoleToPrincipal(
     568            'waeup.CustomerImpersonator', 'mrofficer')
    557569        prmglobal.assignRoleToPrincipal('waeup.CustomersManager', 'mrofficer')
    558570        self.assertEqual(self.customer.state, 'created')
     
    574586        # We are logged in as customer and can see the 'My Data' tab
    575587        self.assertMatches(
    576             '...<a href="#" class="dropdown-toggle" data-toggle="dropdown">...',
     588            '...<a href="#" class="dropdown-toggle"'
     589            ' data-toggle="dropdown">...',
    577590            self.browser.contents)
    578591        self.assertMatches(
     
    724737        self.assertMatches(
    725738            '...<div class="alert alert-warning">'
    726             'Your account has been deactivated.</div>...', self.browser.contents)
     739            'Your account has been deactivated.</div>...',
     740            self.browser.contents)
    727741        # If suspended_comment is set this message will be flashed instead
    728742        self.customer.suspended_comment = u'Aetsch baetsch!'
     
    778792        self.assertTrue('An email with' in self.browser.contents)
    779793
     794
    780795class CustomerRegistrationTests(CustomersFullSetup):
    781796    # Tests for customer registration
     
    823838            cat.searchResults(
    824839            email=('new@yy.zz', 'new@yy.zz')))
    825         self.assertEqual(self.customer,results[0])
     840        self.assertEqual(self.customer, results[0])
    826841        logfile = os.path.join(
    827842            self.app['datacenter'].storage, 'logs', 'main.log')
    828843        logcontent = open(logfile).read()
    829         self.assertTrue('zope.anybody - customers.browser.CustomerRequestPasswordPage - '
    830                         '123 (K1000000) - new@yy.zz' in logcontent)
     844        self.assertTrue(
     845            'zope.anybody - customers.browser.CustomerRequestPasswordPage - '
     846            '123 (K1000000) - new@yy.zz' in logcontent)
    831847        return
    832848
     
    841857        self.browser.getControl(name="form.email").value = 'newcustomer@xx.zz'
    842858        self.browser.getControl("Send login credentials").click()
    843         self.assertTrue('Your request was successful.' in self.browser.contents)
     859        self.assertTrue(
     860            'Your request was successful.' in self.browser.contents)
    844861        # Customer can be found in the catalog via the email address
    845862        cat = queryUtility(ICatalog, name='customers_catalog')
     
    849866        self.assertEqual(self.app['customers']['K1000001'], results[0])
    850867        self.assertEqual(self.app['customers']['K1000001'].firstname, 'Ruben')
    851         self.assertEqual(self.app['customers']['K1000001'].lastname, 'Gonzales')
     868        self.assertEqual(
     869            self.app['customers']['K1000001'].lastname, 'Gonzales')
    852870        logfile = os.path.join(
    853871            self.app['datacenter'].storage, 'logs', 'main.log')
    854872        logcontent = open(logfile).read()
    855         self.assertTrue('zope.anybody - customers.browser.CustomerCreateAccountPage - '
    856                         'K1000001 - newcustomer@xx.zz' in logcontent)
     873        self.assertTrue(
     874            'zope.anybody - customers.browser.CustomerCreateAccountPage - '
     875            'K1000001 - newcustomer@xx.zz' in logcontent)
    857876        return
     877
    858878
    859879class CustomerDataExportTests(CustomersFullSetup, FunctionalAsyncTestCase):
     
    929949        self.browser.getControl("Add document").click()
    930950        self.assertTrue('PDF Document added.' in self.browser.contents)
    931         docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
     951        docid = [i for i in self.customer['documents'].keys()
     952                 if len(i) > 10][0]
    932953        document = self.customer['documents'][docid]
    933954
     
    950971        self.browser.getControl(name="transition").value = ['verify']
    951972        self.browser.getControl("Apply").click()
    952         self.assertTrue('Customer has not yet been approved' in self.browser.contents)
     973        self.assertTrue(
     974            'Customer has not yet been approved' in self.browser.contents)
    953975        IWorkflowState(self.customer).setState(APPROVED)
    954976        # Document can only be verified if files have been uploaded before
     
    958980        self.assertTrue('No file uploaded' in self.browser.contents)
    959981        self.assertEqual(document.state, 'submitted')
    960         # We set state here manually (verification is tested in test_verify_document)
     982        # We set state here manually (verification is tested in
     983        # test_verify_document)
    961984        IWorkflowState(document).setState(VERIFIED)
    962985
     
    964987        self.browser.open(self.documents_path + '/' + docid + '/index')
    965988        self.assertFalse(
    966             'href="http://localhost/app/customers/K1000000/documents/%s/manage"'
     989            'href="http://localhost/app/customers/K1000000/'
     990            'documents/%s/manage"'
    967991            % docid in self.browser.contents)
    968992        self.browser.open(self.documents_path + '/' + docid + '/manage')
     
    10121036        self.browser.getLink("Documents").click()
    10131037        self.browser.getControl("Add document").click()
    1014         self.assertTrue('The requested form is locked' in self.browser.contents)
     1038        self.assertTrue(
     1039            'The requested form is locked' in self.browser.contents)
    10151040        # Customer is in wrong state
    10161041        IWorkflowState(self.customer).setState(APPROVED)
    10171042        self.browser.getControl("Add document").click()
    1018         self.browser.getControl(name="doctype").value = ['CustomerSampleDocument']
     1043        self.browser.getControl(name="doctype").value = [
     1044            'CustomerSampleDocument']
    10191045        self.browser.getControl(name="form.title").value = 'My Sample Document'
    10201046        self.browser.getControl("Add document").click()
    10211047        self.assertTrue('Sample Document added.' in self.browser.contents)
    1022         docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
     1048        docid = [i for i in self.customer['documents'].keys()
     1049                 if len(i) > 10][0]
    10231050        document = self.customer['documents'][docid]
    10241051        self.browser.getControl(name="form.title").value = 'My second doc'
     
    10381065            name='upload_samplescaneditupload').click()
    10391066        self.assertTrue(
    1040             'href="http://localhost/app/customers/K1000000/documents/%s/sample"'
     1067            'href="http://localhost/app/customers/K1000000/'
     1068            'documents/%s/sample"'
    10411069            % docid in self.browser.contents)
    10421070        # Customer can submit the form. The form is also saved.
     
    10451073        self.assertEqual(document.title, 'My third doc')
    10461074        self.assertEqual(document.state, 'submitted')
    1047         self.assertTrue('Document State: submitted for verification' in self.browser.contents)
     1075        self.assertTrue(
     1076            'Document State: submitted for verification'
     1077            in self.browser.contents)
    10481078        # Customer can't edit the document once it has been submitted
    10491079        self.browser.open(self.documents_path + '/%s/edit' % docid)
    1050         self.assertTrue('The requested form is locked' in self.browser.contents)
     1080        self.assertTrue(
     1081            'The requested form is locked' in self.browser.contents)
    10511082
    10521083    def test_manage_upload_sample_file(self):
     
    10551086        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    10561087        self.browser.open(self.customer_path + '/documents/DOC1/manage')
    1057         # Create a pseudo image file and select it to be uploaded 
     1088        # Create a pseudo image file and select it to be uploaded
    10581089        image = open(SAMPLE_IMAGE, 'rb')
    10591090        ctrl = self.browser.getControl(name='samplescanmanageupload')
     
    10611092        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
    10621093        # The Save action does not upload files
    1063         self.browser.getControl("Save").click() # submit form
     1094        self.browser.getControl("Save").click()  # submit form
    10641095        self.assertFalse(
    1065             'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"'
     1096            'href="http://localhost/app/customers/K1000000/'
     1097            'documents/DOC1/sample"'
    10661098            in self.browser.contents)
    10671099        # ... but the correct upload submit button does
     
    10731105            name='upload_samplescanmanageupload').click()
    10741106        self.assertTrue(
    1075             'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"'
     1107            'href="http://localhost/app/customers/K1000000/'
     1108            'documents/DOC1/sample"'
    10761109            in self.browser.contents)
    10771110        # Browsing the link shows a real image
     
    10981131            'Uploaded file is too big' in self.browser.contents)
    10991132        # We do not rely on filename extensions given by uploaders
    1100         image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
     1133        image = open(SAMPLE_IMAGE, 'rb')  # a jpg-file
    11011134        ctrl = self.browser.getControl(name='samplescanmanageupload')
    11021135        file_ctrl = ctrl.mech_control
     
    11521185        self.browser.getControl(name="form.title").value = 'My PDF Document'
    11531186        self.browser.getControl("Add document").click()
    1154         docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
     1187        docid = [
     1188            i for i in self.customer['documents'].keys() if len(i) > 10][0]
    11551189        self.browser.open(self.documents_path + '/%s/manage' % docid)
    11561190        # Create a pseudo image file and select it to be uploaded
     
    11771211            name='upload_pdfscanmanageupload').click()
    11781212        self.assertTrue(
    1179             'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">%s.pdf</a>'
     1213            'href="http://localhost/app/customers/K1000000/'
     1214            'documents/%s/sample.pdf">%s.pdf</a>'
    11801215            % (docid, docid[:9]) in self.browser.contents)
    11811216        # Browsing the link shows a real pdf
     
    11941229        self.browser.getLink("Download documents overview").click()
    11951230        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1196         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1231        self.assertEqual(
     1232            self.browser.headers['Content-Type'], 'application/pdf')
    11971233        path = os.path.join(samples_dir(), 'documents_overview_slip.pdf')
    11981234        open(path, 'wb').write(self.browser.contents)
     
    12001236        # Officers can open document slips which shows a thumbnail of
    12011237        # the jpeg file attached.
    1202         file_id = IFileStoreNameChooser(self.document).chooseName(attr='sample.jpg')
     1238        file_id = IFileStoreNameChooser(self.document).chooseName(
     1239            attr='sample.jpg')
    12031240        fs = ExtFileStore(root=self.dc_root)
    12041241        jpegfile = open(SAMPLE_IMAGE, 'rb')
     
    12071244        self.browser.getLink("Download document slip").click()
    12081245        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1209         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1246        self.assertEqual(
     1247            self.browser.headers['Content-Type'], 'application/pdf')
    12101248        path = os.path.join(samples_dir(), 'document_slip.pdf')
    12111249        open(path, 'wb').write(self.browser.contents)
     
    12161254        self.customer['documents'].addDocument(pdfdocument)
    12171255        # Add pdf file
    1218         file_id = IFileStoreNameChooser(pdfdocument).chooseName(attr='sample.pdf')
     1256        file_id = IFileStoreNameChooser(pdfdocument).chooseName(
     1257            attr='sample.pdf')
    12191258        fs = ExtFileStore(root=self.dc_root)
    12201259        pdffile = open(SAMPLE_PDF, 'rb')
    12211260        fs.createFile(file_id, pdffile)
    1222         docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
     1261        docid = [i for i in self.customer['documents'].keys()
     1262                 if len(i) > 10][0]
    12231263        self.browser.open(self.customer_path + '/documents/' + docid)
    12241264        self.browser.getLink("Download document slip").click()
    12251265        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1226         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1266        self.assertEqual(
     1267            self.browser.headers['Content-Type'], 'application/pdf')
    12271268        path = os.path.join(samples_dir(), 'pdfdocument_slip.pdf')
    12281269        open(path, 'wb').write(self.browser.contents)
     
    12321273        # A proper file name chooser is registered for customer documents.
    12331274        # This is not a UI test. It's just a functional test.
    1234         file_id = IFileStoreNameChooser(self.document).chooseName(attr='sample')
     1275        file_id = IFileStoreNameChooser(self.document).chooseName(
     1276            attr='sample')
    12351277        fs = ExtFileStore(root=self.dc_root)
    12361278        fs.createFile(file_id, StringIO('my sample 1'))
    12371279        result = fs.getFileByContext(self.document, attr='sample')
    1238         self.assertEqual(file_id, '__file-customerdocument__01000/K1000000/sample_DOC1_K1000000')
     1280        self.assertEqual(
     1281            file_id, '__file-customerdocument__01000/'
     1282            'K1000000/sample_DOC1_K1000000')
    12391283        self.assertEqual(result.read(), 'my sample 1')
    1240         self.assertEqual(self.document.connected_files[0][1].read(), 'my sample 1')
     1284        self.assertEqual(
     1285            self.document.connected_files[0][1].read(), 'my sample 1')
    12411286        self.document.setMD5()
    1242         self.assertEqual(self.document.sample_md5, 'a406995ee8eb6772bacf51aa4b0caa24')
     1287        self.assertEqual(
     1288            self.document.sample_md5, 'a406995ee8eb6772bacf51aa4b0caa24')
    12431289        return
    12441290
     
    12611307        self.browser.getControl("Add contract").click()
    12621308        self.assertTrue('Sample Contract added.' in self.browser.contents)
    1263         conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
     1309        conid = [i for i in self.customer['contracts'].keys()
     1310                 if len(i) > 10][0]
    12641311        contract = self.customer['contracts'][conid]
    12651312        self.assertEqual(
    1266             self.browser.url, self.contracts_path + '/%s/selectproduct' % conid)
     1313            self.browser.url,
     1314            self.contracts_path + '/%s/selectproduct' % conid)
    12671315        # SAM is in the correct contract_category
    12681316        self.assertTrue('<option value="SAM">' in self.browser.contents)
    12691317        # So far last_product_id is None.
    1270         self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
     1318        self.assertTrue(
     1319            self.customer['contracts'][conid].last_product_id is None)
    12711320        self.browser.getControl(name="form.product_object").value = ['SAM']
    12721321        self.browser.getControl("Save and proceed").click()
     
    12741323            self.browser.url, self.contracts_path + '/%s/manage' % conid)
    12751324        self.browser.getLink("View").click()
    1276         self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
     1325        self.assertEqual(
     1326            self.browser.url, self.contracts_path + '/%s/index' % conid)
    12771327        self.assertEqual(contract.tc_dict, {'en': u'Hello world'})
    12781328
     
    13421392        self.assertFalse('Add contract' in self.browser.contents)
    13431393        self.browser.open(self.contracts_path + '/addcontract')
    1344         self.assertTrue('The requested form is locked' in self.browser.contents)
     1394        self.assertTrue(
     1395            'The requested form is locked' in self.browser.contents)
    13451396        IWorkflowState(self.customer).setState(APPROVED)
    13461397        self.browser.open(self.contracts_path)
     
    13501401        self.browser.getControl("Add contract").click()
    13511402        self.assertTrue('Sample Contract added.' in self.browser.contents)
    1352         conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
     1403        conid = [i for i in self.customer['contracts'].keys()
     1404                 if len(i) > 10][0]
    13531405        contract = self.customer['contracts'][conid]
    13541406        self.assertEqual(
    1355             self.browser.url, self.contracts_path + '/%s/selectproduct' % conid)
     1407            self.browser.url,
     1408            self.contracts_path + '/%s/selectproduct' % conid)
    13561409        # SAM is in the correct contract_category ...
    13571410        self.assertTrue('<option value="SAM">' in self.browser.contents)
     
    13591412        self.assertFalse('<option value="LIC">' in self.browser.contents)
    13601413        # So far last_product_id is None.
    1361         self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
     1414        self.assertTrue(
     1415            self.customer['contracts'][conid].last_product_id is None)
    13621416        self.browser.getControl(name="form.product_object").value = ['SAM']
    13631417        self.browser.getControl("Save and proceed").click()
     
    13661420        # Document is a required field on edit form page.
    13671421        self.browser.getControl("Save").click()
    1368         self.assertTrue('Document: <span class="error">Required input is missing.</span>'
     1422        self.assertTrue(
     1423            'Document: <span class="error">Required input is missing.</span>'
    13691424            in self.browser.contents)
    13701425        # But our document can't be selected because it's not submitted
     
    13761431        # After saving the form, last_product_id and other attributes are set
    13771432        self.assertTrue('Form has been saved.' in self.browser.contents)
    1378         self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
     1433        self.assertEqual(
     1434            self.customer['contracts'][conid].last_product_id, 'SAM')
    13791435        self.assertEqual(contract.title, 'Our Sample Product')
    13801436        self.assertEqual(contract.product_object, self.product)
     
    13821438        # Saving the form again does not unset last_product_id
    13831439        self.browser.getControl("Save").click()
    1384         self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
     1440        self.assertEqual(
     1441            self.customer['contracts'][conid].last_product_id, 'SAM')
    13851442        self.assertTrue('Form has been saved.' in self.browser.contents)
    13861443        # So far we have not yet set product options.
     
    13901447        prodoption.fee = Decimal('88.8')
    13911448        prodoption.currency = 'EUR'
    1392         contract.product_options = [prodoption,]
     1449        contract.product_options = [prodoption, ]
    13931450        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    13941451        # We can see both the stored and the recent product options
    13951452        # from the chosen product.
    1396         self.assertTrue('<option selected="selected" value="Any product option">'
    1397                         'Any product option @ 88.8 Euro</option>'
    1398                         in self.browser.contents)
     1453        self.assertTrue(
     1454            '<option selected="selected" value="Any product option">'
     1455            'Any product option @ 88.8 Euro</option>'
     1456            in self.browser.contents)
    13991457        self.assertTrue('<option value="First option">First option '
    14001458                        '@ 99.9 US Dollar</option>' in self.browser.contents)
     
    14021460        self.browser.getControl(
    14031461            name="form.product_options.0.").value = ['First option']
    1404         self.assertEqual(contract.product_options[0].title, 'Any product option')
     1462        self.assertEqual(
     1463            contract.product_options[0].title, 'Any product option')
    14051464        self.browser.getControl("Save").click()
    14061465        self.assertEqual(contract.product_options[0].title, 'First option')
    14071466        self.browser.getLink("View").click()
    1408         self.assertTrue('<span>First option @ 99.9 US Dollar</span>' in self.browser.contents)
    1409         self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
     1467        self.assertTrue(
     1468            '<span>First option @ 99.9 US Dollar</span>'
     1469            in self.browser.contents)
     1470        self.assertEqual(
     1471            self.browser.url, self.contracts_path + '/%s/index' % conid)
    14101472        # An href attribute is referring to the document and product objects
    14111473        self.assertTrue('<a href="http://localhost/app/products/SAM">SAM -'
    14121474            in self.browser.contents)
    14131475        self.assertTrue(
    1414             '<a href="http://localhost/app/customers/K1000000/documents/DOC1">DOC1 -'
     1476            '<a href="http://localhost/app/customers/K1000000/'
     1477            'documents/DOC1">DOC1 -'
    14151478            in self.browser.contents)
    14161479        # Customer can submit the form if confirmation box is ticket.
     
    14181481        self.browser.getLink("Edit").click()
    14191482        self.browser.getControl("Proceed to checkout").click()
    1420         self.assertTrue('confirm your acceptance of these by ticking' in self.browser.contents)
     1483        self.assertTrue(
     1484            'confirm your acceptance of these by ticking'
     1485            in self.browser.contents)
    14211486        self.assertEqual(contract.state, 'created')
    14221487        self.browser.getControl(name="confirm_tc").value = True
     
    14291494        # Customer can't edit the contract once it has been submitted
    14301495        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    1431         self.assertTrue('The requested form is locked' in self.browser.contents)
     1496        self.assertTrue(
     1497            'The requested form is locked' in self.browser.contents)
    14321498
    14331499    def test_view_slips(self):
     
    14371503        self.browser.getLink("Download contracts overview").click()
    14381504        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1439         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1505        self.assertEqual(
     1506            self.browser.headers['Content-Type'], 'application/pdf')
    14401507        path = os.path.join(samples_dir(), 'contracts_overview_slip.pdf')
    14411508        open(path, 'wb').write(self.browser.contents)
     
    14531520        self.browser.getLink("Download contract slip").click()
    14541521        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1455         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1522        self.assertEqual(
     1523            self.browser.headers['Content-Type'], 'application/pdf')
    14561524        path = os.path.join(samples_dir(), 'contract_slip.pdf')
    14571525        open(path, 'wb').write(self.browser.contents)
     
    14881556        # InvalidTransitionError is catched
    14891557        self.assertTrue(
    1490             '<div class="alert alert-warning">Attached documents must be verified first.</div>'
     1558            '<div class="alert alert-warning">Attached documents '
     1559            'must be verified first.</div>'
    14911560            in self.browser.contents)
    14921561        self.browser.open(self.contracts_path + '/CON1/trigtrans')
     
    15011570        prodoption.fee = Decimal('88.8')
    15021571        prodoption.currency = 'EUR'
    1503         contract.product_options = [prodoption,]
     1572        contract.product_options = [prodoption, ]
    15041573
    15051574    def prepare_payment_select(self):
Note: See TracChangeset for help on using the changeset viewer.