Ignore:
Timestamp:
24 Dec 2014, 16:00:58 (10 years ago)
Author:
Henrik Bettermann
Message:

Test and fix export of ProductOptionEntry? lists.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/products
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/export.py

    r12077 r12315  
    4848            for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
    4949                value.append({'user_name':user_name,'local_role':local_role})
     50        if name == 'options' and value is not None:
     51            value = [eval(entry.to_string()) for entry in value]
    5052        return super(ProductExporter, self).mangle_value(
    5153            value, name, context)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_batching.py

    r12288 r12315  
    2525import datetime
    2626import grok
     27from decimal import Decimal
    2728from time import time
    2829from zope.event import notify
     
    3738from waeup.ikoba.products.batching import ProductProcessor
    3839from waeup.ikoba.products.product import Product
     40from waeup.ikoba.products.productoptions import ProductOptionEntry
    3941from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    4042
     
    8183        product = Product()
    8284        product.product_id = u'LIC'
     85        options = ProductOptionEntry()
     86        options.title = u'Base Fee'
     87        options.fee = Decimal('800.6')
     88        options.currency = 'usd'
     89        product.options = [options,]
    8390        self.app['products'][product.product_id] = self.product = product
    8491        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_export.py

    r12097 r12315  
    6262        result = open(self.outfile, 'rb').read()
    6363        self.assertTrue(
    64             'contract_category,product_id,title,users_with_local_roles\r\n'
    65             'license,LIC,Unnamed,"[{\'user_name\': u\'john\', \'local_role\': '
     64            'contract_category,options,product_id,title,users_with_local_roles\r\n'
     65            'license,"[(u\'Base Fee\', u\'800.6\', u\'usd\')]",LIC,Unnamed,'
     66            '"[{\'user_name\': u\'john\', \'local_role\': '
    6667            'u\'johnsrole\'}]"\r\n'
    6768            in result
     
    7576        result = open(self.outfile, 'rb').read()
    7677        self.assertTrue(
    77             'contract_category,product_id,title,users_with_local_roles\r\n'
    78             'license,LIC,Unnamed,"[{\'user_name\': u\'john\', \'local_role\': '
     78            'contract_category,options,product_id,title,users_with_local_roles\r\n'
     79            'license,"[(u\'Base Fee\', u\'800.6\', u\'usd\')]",LIC,Unnamed,'
     80            '"[{\'user_name\': u\'john\', \'local_role\': '
    7981            'u\'johnsrole\'}]"\r\n'
    8082            in result
Note: See TracChangeset for help on using the changeset viewer.