Exemple #1
0
 def test_set_field(self):
     price_field = AccessorField('Test', None, 'base_price', Decimal)
     cost_field = AccessorField('Test', None, 'cost', Decimal)
     operation = MultiplyOperation(self.store, price_field, [])
     self.assertEqual(operation._field, price_field)
     operation.set_field(cost_field)
     self.assertEqual(operation._field, cost_field)
Exemple #2
0
    def test_multiply(self):
        sellable = self.create_sellable()
        sellable.cost = 100
        sellable.base_price = 1

        price_field = AccessorField('Test', None, 'base_price', Decimal)
        cost_field = AccessorField('Test', None, 'cost', Decimal)
        operation = MultiplyOperation(self.store, price_field, [cost_field])
        operation.combo.select(cost_field)
        operation.entry.set_text('3')

        self.assertEqual(price_field.get_new_value(sellable), 1)
        operation.apply_operation(sellable)
        self.assertEqual(price_field.get_new_value(sellable), 300)

        # An invalid value should not change the object
        operation.entry.set_text('foo')
        operation.apply_operation(sellable)
        self.assertEqual(price_field.get_new_value(sellable), 300)