Ignore:
Timestamp:
25 Nov 2014, 13:15:27 (10 years ago)
Author:
Henrik Bettermann
Message:

Use a baseclass for customer documents. That eases file viewlet configuration.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_document_data.csv

    r12056 r12057  
    11class_name,document_id,reg_number,title
    2 CustomerDocument,d3,1,My first doc
    3 CustomerDocument,d4,2,My second doc
    4 CustomerDocument,d5,3,My third doc
    5 CustomerDocument,,1,My 4th doc
    6 CustomerDocument,d5,2,My stolen doc
     2CustomerSampleDocument,d3,1,My first doc
     3CustomerSampleDocument,d4,2,My second doc
     4CustomerSampleDocument,d5,3,My third doc
     5CustomerSampleDocument,,1,My 4th doc
     6CustomerSampleDocument,d5,2,My stolen doc
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12056 r12057  
    3838    CustomerProcessor, CustomerDocumentProcessor)
    3939from waeup.ikoba.customers.customer import Customer
    40 from waeup.ikoba.customers.documents import CustomerDocument
     40from waeup.ikoba.customers.documents import CustomerSampleDocument
    4141from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    4242
     
    117117        customer.nationality = u'NG'
    118118
    119         document = CustomerDocument()
     119        document = CustomerSampleDocument()
    120120        document.title = u'My Document'
    121121        customer['documents'].addDocument(document)
     
    262262        self.app['customers'].addCustomer(customer)
    263263        self.customer = self.app['customers'][customer.customer_id]
    264         document = createObject(u'waeup.CustomerDocument')
     264        document = createObject(u'waeup.CustomerSampleDocument')
    265265        document.document_id = 'd120'
    266266        self.customer['documents'][document.document_id] = document
     
    306306    def test_addEntry(self):
    307307        self.assertEqual(len(self.customer['documents'].keys()),1)
    308         document1 = createObject(u'waeup.CustomerDocument')
     308        document1 = createObject(u'waeup.CustomerSampleDocument')
    309309        document1.document_id = 'p234'
    310310        self.processor.addEntry(
     
    313313        self.assertEqual(len(self.customer['documents'].keys()),2)
    314314        self.assertEqual(self.customer['documents']['p234'].document_id, 'p234')
    315         document2 = createObject(u'waeup.CustomerDocument')
     315        document2 = createObject(u'waeup.CustomerSampleDocument')
    316316        document1.document_id = 'nonsense'
    317317
    318318    def test_checkConversion(self):
    319319        errs, inv_errs, conv_dict = self.processor.checkConversion(
    320             dict(document_id='d1266236341955', class_name='CustomerDocument'))
     320            dict(document_id='d1266236341955', class_name='CustomerSampleDocument'))
    321321        self.assertEqual(len(errs),0)
    322322        errs, inv_errs, conv_dict = self.processor.checkConversion(
    323             dict(document_id='nonsense', class_name='CustomerDocument'))
     323            dict(document_id='nonsense', class_name='CustomerSampleDocument'))
    324324        self.assertEqual(len(errs),1)
    325325        timestamp = ("%d" % int(time()*10000))[1:]
    326326        document_id = "d%s" % timestamp
    327327        errs, inv_errs, conv_dict = self.processor.checkConversion(
    328             dict(document_id=document_id, class_name='CustomerDocument'))
     328            dict(document_id=document_id, class_name='CustomerSampleDocument'))
    329329        self.assertEqual(len(errs),0)
    330330        errs, inv_errs, conv_dict = self.processor.checkConversion(
     
    340340        self.assertEqual(fail_file,
    341341            'class_name,reg_number,document_id,title,--ERRORS--\r\n'
    342             'CustomerDocument,2,d5,My stolen doc,document_id: id exists\r\n')
     342            'CustomerSampleDocument,2,d5,My stolen doc,document_id: id exists\r\n')
    343343        document = self.processor.getEntry(dict(reg_number='1',
    344344            document_id='d3'), self.app)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12053 r12057  
    103103        self.customer_id = customer.customer_id
    104104        self.customer = self.app['customers'][self.customer_id]
    105         document = createObject('waeup.CustomerDocument')
     105        document = createObject('waeup.CustomerSampleDocument')
    106106        document.title = u'My first document'
    107107        self.customer['documents'].addDocument(document)
     
    800800
    801801class DocumentUITests(CustomersFullSetup):
    802     # Tests for CustomerDocument relates views and pages
     802    # Tests for CustomerSampleDocument relates views and pages
    803803
    804804    def test_manage_document(self):
     
    871871        self.browser.getLink("Documents").click()
    872872        self.browser.getLink("Add document").click()
    873         self.browser.getControl(name="doctype").value = ['CustomerDocument']
     873        self.browser.getControl(name="doctype").value = ['CustomerSampleDocument']
    874874        self.browser.getControl("Create document").click()
    875875        self.assertTrue('Sample Document created.' in self.browser.contents)
     
    892892        # Costumer can upload a document.
    893893        self.browser.getLink("Edit").click()
    894         ctrl = self.browser.getControl(name='scaneditupload')
     894        ctrl = self.browser.getControl(name='sampleeditupload')
    895895        file_obj = open(SAMPLE_IMAGE, 'rb')
    896896        file_ctrl = ctrl.mech_control
    897897        file_ctrl.add_file(file_obj, filename='my_document.jpg')
    898898        self.browser.getControl(
    899             name='upload_scaneditupload').click()
    900         self.assertTrue(
    901             'href="http://localhost/app/customers/K1000000/documents/d102/scan"'
     899            name='upload_sampleeditupload').click()
     900        self.assertTrue(
     901            'href="http://localhost/app/customers/K1000000/documents/d102/sample"'
    902902            in self.browser.contents)
    903903        # Costumer can submit the form. The form is also saved.
     
    918918        # Create a pseudo image file and select it to be uploaded
    919919        image = open(SAMPLE_IMAGE, 'rb')
    920         ctrl = self.browser.getControl(name='scanmanageupload')
     920        ctrl = self.browser.getControl(name='samplemanageupload')
    921921        file_ctrl = ctrl.mech_control
    922         file_ctrl.add_file(image, filename='my_scan.jpg')
     922        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
    923923        # The Save action does not upload files
    924924        self.browser.getControl("Save").click() # submit form
    925925        self.assertFalse(
    926             'href="http://localhost/app/customers/K1000000/documents/d101/scan"'
     926            'href="http://localhost/app/customers/K1000000/documents/d101/sample"'
    927927            in self.browser.contents)
    928928        # ... but the correct upload submit button does
    929929        image = open(SAMPLE_IMAGE)
    930         ctrl = self.browser.getControl(name='scanmanageupload')
     930        ctrl = self.browser.getControl(name='samplemanageupload')
    931931        file_ctrl = ctrl.mech_control
    932         file_ctrl.add_file(image, filename='my_scan.jpg')
    933         self.browser.getControl(
    934             name='upload_scanmanageupload').click()
    935         self.assertTrue(
    936             'href="http://localhost/app/customers/K1000000/documents/d101/scan"'
     932        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
     933        self.browser.getControl(
     934            name='upload_samplemanageupload').click()
     935        self.assertTrue(
     936            'href="http://localhost/app/customers/K1000000/documents/d101/sample"'
    937937            in self.browser.contents)
    938938        # Browsing the link shows a real image
    939         self.browser.open('scan')
     939        self.browser.open('sample')
    940940        self.assertEqual(
    941941            self.browser.headers['content-type'], 'image/jpeg')
     
    944944        self.browser.open(self.customer_path + '/documents/d101/manage')
    945945        self.assertFalse(
    946             'upload_scanmanageupload' in self.browser.contents)
     946            'upload_samplemanageupload' in self.browser.contents)
    947947        # File must be deleted first
    948         self.browser.getControl(name='delete_scanmanageupload').click()
    949         self.assertTrue(
    950             'scan deleted' in self.browser.contents)
     948        self.browser.getControl(name='delete_samplemanageupload').click()
     949        self.assertTrue(
     950            'sample deleted' in self.browser.contents)
    951951        # Uploading a file which is bigger than 150k will raise an error
    952952        big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75)
    953         ctrl = self.browser.getControl(name='scanmanageupload')
     953        ctrl = self.browser.getControl(name='samplemanageupload')
    954954        file_ctrl = ctrl.mech_control
    955         file_ctrl.add_file(big_image, filename='my_scan.jpg')
    956         self.browser.getControl(
    957             name='upload_scanmanageupload').click()
     955        file_ctrl.add_file(big_image, filename='my_sample_scan.jpg')
     956        self.browser.getControl(
     957            name='upload_samplemanageupload').click()
    958958        self.assertTrue(
    959959            'Uploaded file is too big' in self.browser.contents)
    960960        # we do not rely on filename extensions given by uploaders
    961961        image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
    962         ctrl = self.browser.getControl(name='scanmanageupload')
     962        ctrl = self.browser.getControl(name='samplemanageupload')
    963963        file_ctrl = ctrl.mech_control
    964964        # tell uploaded file is bmp
    965         file_ctrl.add_file(image, filename='my_scan.bmp')
    966         self.browser.getControl(
    967             name='upload_scanmanageupload').click()
     965        file_ctrl.add_file(image, filename='my_sample_scan.bmp')
     966        self.browser.getControl(
     967            name='upload_samplemanageupload').click()
    968968        self.assertTrue(
    969969            # jpg file was recognized
    970             'File scan.jpg uploaded.' in self.browser.contents)
     970            'File sample.jpg uploaded.' in self.browser.contents)
    971971        # Delete file again
    972         self.browser.getControl(name='delete_scanmanageupload').click()
    973         self.assertTrue(
    974             'scan deleted' in self.browser.contents)
     972        self.browser.getControl(name='delete_samplemanageupload').click()
     973        self.assertTrue(
     974            'sample deleted' in self.browser.contents)
    975975        # File names must meet several conditions
    976976        bmp_image = open(SAMPLE_IMAGE_BMP, 'rb')
    977         ctrl = self.browser.getControl(name='scanmanageupload')
     977        ctrl = self.browser.getControl(name='samplemanageupload')
    978978        file_ctrl = ctrl.mech_control
    979         file_ctrl.add_file(bmp_image, filename='my_scan.bmp')
    980         self.browser.getControl(
    981             name='upload_scanmanageupload').click()
     979        file_ctrl.add_file(bmp_image, filename='my_sample_scan.bmp')
     980        self.browser.getControl(
     981            name='upload_samplemanageupload').click()
    982982        self.assertTrue('Only the following extensions are allowed'
    983983            in self.browser.contents)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_document.py

    r12056 r12057  
    2727from waeup.ikoba.interfaces import IObjectHistory
    2828from waeup.ikoba.customers.documents import (
    29     CustomerDocumentsContainer, CustomerDocument)
     29    CustomerDocumentsContainer, CustomerSampleDocument)
    3030from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
    3131
     
    4646        self.assertTrue(
    4747            verifyClass(
    48                 ICustomerDocument, CustomerDocument)
     48                ICustomerDocument, CustomerSampleDocument)
    4949            )
    5050        self.assertTrue(
    5151            verifyObject(
    52                 ICustomerDocument, CustomerDocument())
     52                ICustomerDocument, CustomerSampleDocument())
    5353            )
    5454        return
     
    5656    def test_addDocument(self):
    5757        container = CustomerDocumentsContainer()
    58         document = createObject(u'waeup.CustomerDocument')
     58        document = createObject(u'waeup.CustomerSampleDocument')
    5959        id = document.document_id
    6060        container.addDocument(document)
    6161        self.assertEqual(container[id], document)
    6262        self.assertRaises(TypeError, container.addDocument, object())
    63         self.assertEqual(document.class_name, 'CustomerDocument')
     63        self.assertEqual(document.class_name, 'CustomerSampleDocument')
    6464        return
    6565
    6666    def test_document_workflow(self):
    67         document = createObject(u'waeup.CustomerDocument')
     67        document = createObject(u'waeup.CustomerSampleDocument')
    6868        IWorkflowInfo(document).fireTransition('create')
    6969        self.assertEqual(IWorkflowState(document).getState(), 'created')
     
    8282
    8383    def test_document_history(self):
    84         doc = createObject(u'waeup.CustomerDocument')
     84        doc = createObject(u'waeup.CustomerSampleDocument')
    8585        IWorkflowInfo(doc).fireTransition('create')
    8686        messages = ' '.join(doc.history.messages)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py

    r12056 r12057  
    1313from waeup.ikoba.customers.interfaces import ICSVCustomerExporter
    1414from waeup.ikoba.customers.customer import Customer
    15 from waeup.ikoba.customers.documents import CustomerDocument
     15from waeup.ikoba.customers.documents import CustomerSampleDocument
    1616from waeup.ikoba.customers.tests.test_batching import CustomerImportExportSetup
    1717from waeup.ikoba.testing import FunctionalLayer
     
    132132    def test_export_empty(self):
    133133        # we can export a nearly empty document
    134         document = CustomerDocument()
     134        document = CustomerSampleDocument()
    135135        exporter = CustomerDocumentsExporter()
    136136        exporter.export([document], self.outfile)
     
    139139            result,
    140140            'class_name,document_id,history,last_transition_date,state,title,customer_id\r\n'
    141             'CustomerDocument,d101,[],,,,\r\n'
     141            'CustomerSampleDocument,d101,[],,,,\r\n'
    142142            )
    143143        return
     
    156156            )
    157157        self.assertMatches(
    158             '...CustomerDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
     158            '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
    159159            'Document created by system\'],2014-11-25 06:57:24.990308#,'
    160160            'created,My Document,A111111...',
     
    174174            in result)
    175175        self.assertMatches(
    176             '...CustomerDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
     176            '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
    177177            'Document created by system\'],2014-11-25 06:57:24.990308#,'
    178178            'created,My Document,A111111...',
     
    192192            in result)
    193193        self.assertMatches(
    194             '...CustomerDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
     194            '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
    195195            'Document created by system\'],2014-11-25 06:57:24.990308#,'
    196196            'created,My Document,A111111...',
Note: See TracChangeset for help on using the changeset viewer.