[Erp5-dev] How to test quantity step?

Łukasz Nowak lukasz.nowak at ventis.com.pl
Wed Oct 10 11:37:56 CEST 2007


Hello,

I'm playing lot with purchase supplies and I'd like to write test for
quantity step on purchase supply line.

I create Purchase Supply, in it Purchase Supply Line, associated
resource with it, then:

def stepFillPurchaseSupplyLineDefineRange(self, sequence=None, **kw):
  purchase_supply_line = sequence.get('purchase_supply_line')
  purchase_supply_line.setQuantityStepList([5.0,10.0])

Now tic is invoked and then:

price_matrix_list = [
  {
    'range' : {
      'min' : None,
      'max' : 5.0,
    },
    'update_dict' : {
      'base_price' : low_quantity_price,
    },
  },
  {
    'range' : {
      'min' : 5.0,
      'max' : 10.0,
    },
    'update_dict' : {
      'base_price' : medium_quantity_price,
    },
  },
  {
    'range' : {
      'min' : 10.0,
      'max' : None,
    },
    'update_dict' : {
      'base_price' : high_quantity_price,
    },
  },
]

def stepFillPurchaseSupplyLineFillRange(self, sequence=None, **kw):
  purchase_supply_line = sequence.get('purchase_supply_line')

  id = 0
  for cell_dict in self.price_matrix_list:
    purchase_supply_cell = purchase_supply_line.newContent(
      portal_type = self.purchase_supply_cell_portal_type,
      id = 'path_%s'%(id,)
    )
    purchase_supply_cell.setCriterionProperty('quantity')
    purchase_supply_cell.edit(**cell_dict['update_dict'])
    purchase_supply_cell.setCriterion('quantity',**cell_dict['range'])
    id = id + 1

Tic again. Then I do pdb on test - navigate to created Purchase Supply
Line and matrix is filled.

Then I'm creating Purchase Order which find this matrix as predicate.
But it do not this. But if I navigate again to created PSL and edit eg.
base_price from UI, go to portal_activities, invoke all of them then
prices are copied to Purchase Order Lines...

I've seen then supply_line_interaction workflow is associated to method
_setQuantityStepList - but AFAIK it do not matter - and it do not
matter - even if I use _setQuantityStepList instead of
setQuantityStepList those activities aren't invoked.

I tried to search for similar test, but grep didn't helped me too much.

Any suggestions? What API (if any available) shall be used from unit
test point of view? While using UI everything works fine, but my
knowledge about tracing zope-ish invocations is not good enough to
track it down.

Regards,
Luke

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...''



More information about the Erp5-dev mailing list