Beispiel #1
0
    def test_03_mixed_currencies(self):
        """Test orders with mixed currencies are rejected during validation"""

        p1 = self.create_product()
        p2 = self.create_product()
        order = self.create_order()

        order.currency = "CHF"
        order.modify_item(p1, 3)

        order.currency = "EUR"
        self.assertRaisesWithCode(ValidationError,
                                  lambda: order.modify_item(p2, 2),
                                  code="multiple_currency")

        # Validation should still fail
        self.assertRaisesWithCode(
            ValidationError,
            lambda: order.validate(order.VALIDATE_BASE),
            code="multiple_currency",
        )

        order.currency = "CHF"
        # Order should validate now
        order.validate(order.VALIDATE_BASE)
    def test_03_mixed_currencies(self):
        """Test orders with mixed currencies are rejected during validation"""

        p1 = self.create_product()
        p2 = self.create_product()
        order = self.create_order()

        order.currency = 'CHF'
        i1 = order.modify_item(p1.variations.get(), 3)

        order.currency = 'EUR'
        self.assertRaisesWithCode(ValidationError, lambda: order.modify_item(p2.variations.get(), 2),
            code='multiple_currency')

        # Validation should still fail
        self.assertRaisesWithCode(ValidationError, lambda: order.validate(order.VALIDATE_BASE),
            code='multiple_currency')

        order.currency = 'CHF'
        # Order should validate now
        order.validate(order.VALIDATE_BASE)