Ignore:
Timestamp:
20 Jan 2015, 08:31:25 (10 years ago)
Author:
Henrik Bettermann
Message:

Add second batch of contract components which are so far a copy of the IRONContract components.

Location:
main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests/test_browser.py

    r12488 r12499  
    3434    PCNCustomerPDFDocumentExporter,
    3535    PCNCustomerJPGDocumentExporter,
    36     RONContractExporter)
     36    RONContractExporter,
     37    ROPContractExporter)
    3738from ikobacustom.pcn.customers.batching import (
    3839    PCNCustomerProcessor,
    3940    PCNCustomerPDFDocumentProcessor,
    4041    PCNCustomerJPGDocumentProcessor,
    41     RONContractProcessor)
     42    RONContractProcessor,
     43    ROPContractProcessor)
    4244from ikobacustom.pcn.testing import FunctionalLayer, samples_dir
    4345
     
    6870        customer['documents'].addDocument(document1)
    6971        customer['documents'].addDocument(document2)
    70         contract = createObject(u'waeup.RONContract')
    71         contract.tc_dict = {'en':u'Hello World'}
    72         customer['contracts'].addContract(contract)
     72        contract1 = createObject(u'waeup.RONContract')
     73        contract1.tc_dict = {'en':u'Hello World'}
     74        customer['contracts'].addContract(contract1)
     75        contract2 = createObject(u'waeup.ROPContract')
     76        contract2.tc_dict = {'en':u'Hello World'}
     77        customer['contracts'].addContract(contract2)
    7378        self.customer = customer
    7479        self.document1 = document1
    7580        self.document2 = document2
    76         self.contract = contract
     81        self.contract1 = contract1
     82        self.contract2 = contract2
    7783        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
    7884        return
     
    206212        return
    207213
    208     def test_export_reimport_contracts(self):
     214    def test_export_reimport_roncontracts(self):
    209215        # we can export all contracts in a portal
    210216        # set values we can expect in export file
     
    222228            '[u\'2015-01-18 16:40:01 WAT - Contract created by system\'],,,,'
    223229            '[],,created,,,{\'en\': u\'Hello World\'},,K1000000,,,,\r\n'
    224             % self.contract.contract_id)
     230            % self.contract1.contract_id)
    225231        # We can reimport the file if we change the header
    226232        # (user_id -> customer_id). Not all columns are necessary.
     
    233239            '[u\'2014-12-21 22:26:00 WAT - Contract created by system\']'
    234240            ',,,[],created,{\'en\': u\'Hello World\'},,K1000000\r\n'
    235             % self.contract.contract_id)
     241            % self.contract1.contract_id)
    236242        result = processor.doImport(
    237243            self.outfile,
     
    244250        self.assertEqual(num_fail,1)
    245251        # We remove the original contract.
    246         del self.customer['contracts'][self.contract.contract_id]
     252        del self.customer['contracts'][self.contract1.contract_id]
     253        result = processor.doImport(
     254            self.outfile,
     255            ['class_name','contract_category','contract_id','document_object',
     256            'history','last_product_id','product_object','product_options',
     257            'state','tc_dict','title','customer_id'],
     258            mode='create')
     259        num_succ, num_fail, finished_path, failed_path = result
     260        self.assertEqual(num_fail,0)
     261        # We can import the same file in update mode.
     262        result = processor.doImport(
     263            self.outfile,
     264            ['class_name','contract_category','contract_id','document_object',
     265            'history','last_product_id','product_object','product_options',
     266            'state','tc_dict','title','customer_id'],
     267            mode='update')
     268        num_succ, num_fail, finished_path, failed_path = result
     269        self.assertEqual(num_succ,1)
     270        self.assertEqual(num_fail,0)
     271        return
     272
     273    def test_export_reimport_ropcontracts(self):
     274        # we can export all contracts in a portal
     275        # set values we can expect in export file
     276        self.setup_for_export()
     277        exporter = ROPContractExporter()
     278        exporter.export_all(self.app, self.outfile)
     279        result = open(self.outfile, 'rb').read()
     280        self.assertMatches(result,
     281            'category_practice,class_name,contract_category,contract_id,'
     282            'date_of_birth,history,last_product_id,lga,product_object,'
     283            'product_options,res_address,state,state_of_origin,superintendent,'
     284            'tc_dict,title,user_id,work_address,work_email,work_phone,'
     285            'year_qualification\r\n'
     286            ',ROPContract,rop,%s,,'
     287            '[u\'2015-01-18 16:40:01 WAT - Contract created by system\'],,,,'
     288            '[],,created,,,{\'en\': u\'Hello World\'},,K1000000,,,,\r\n'
     289            % self.contract2.contract_id)
     290        # We can reimport the file if we change the header
     291        # (user_id -> customer_id). Not all columns are necessary.
     292        processor = ROPContractProcessor()
     293        open(self.outfile, 'wb').write(
     294            'class_name,contract_category,contract_id,document_object,'
     295            'history,last_product_id,product_object,product_options,'
     296            'state,tc_dict,title,user_id\r\n'
     297            'ROPContract,rop,%s,,'
     298            '[u\'2014-12-21 22:26:00 WAT - Contract created by system\']'
     299            ',,,[],created,{\'en\': u\'Hello World\'},,K1000000\r\n'
     300            % self.contract2.contract_id)
     301        result = processor.doImport(
     302            self.outfile,
     303            ['class_name','contract_category','contract_id','document_object',
     304            'history','last_product_id','product_object','product_options',
     305            'state','tc_dict','title','customer_id'],
     306            mode='create')
     307        num, num_fail, finished_path, failed_path = result
     308        # The object exists.
     309        self.assertEqual(num_fail,1)
     310        # We remove the original contract.
     311        del self.customer['contracts'][self.contract2.contract_id]
    247312        result = processor.doImport(
    248313            self.outfile,
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests/test_contract.py

    r12484 r12499  
    2929
    3030from ikobacustom.pcn.testing import (FunctionalLayer, FunctionalTestCase)
    31 from ikobacustom.pcn.customers.contracts import RONContract
    32 from ikobacustom.pcn.customers.interfaces import IRONContract
     31from ikobacustom.pcn.customers.contracts import RONContract, ROPContract
     32from ikobacustom.pcn.customers.interfaces import IRONContract, IROPContract
    3333
    3434
     
    4242        verify.verifyObject(IRONContract, RONContract())
    4343        verify.verifyObject(ICustomerNavigation, RONContract())
     44        verify.verifyObject(IROPContract, ROPContract())
     45        verify.verifyObject(ICustomerNavigation, ROPContract())
    4446        return
    4547
    4648    def test_addContract(self):
    4749        container = ContractsContainer()
    48         contract = createObject(u'waeup.RONContract')
    49         id = contract.contract_id
    50         container.addContract(contract)
    51         self.assertEqual(container[id], contract)
     50        contract1 = createObject(u'waeup.RONContract')
     51        id1 = contract1.contract_id
     52        container.addContract(contract1)
     53        self.assertEqual(container[id1], contract1)
    5254        self.assertRaises(TypeError, container.addContract, object())
    53         self.assertEqual(contract.class_name, 'RONContract')
     55        self.assertEqual(contract1.class_name, 'RONContract')
     56
     57        contract2 = createObject(u'waeup.ROPContract')
     58        id2 = contract2.contract_id
     59        container.addContract(contract2)
     60        self.assertEqual(container[id2], contract2)
     61        self.assertRaises(TypeError, container.addContract, object())
     62        self.assertEqual(contract2.class_name, 'ROPContract')
    5463        return
Note: See TracChangeset for help on using the changeset viewer.