示例#1
0
    def test_get_subtotal(self):
        """
        subtotal should always be product price * quantity
        """
        det = Detail()
        assert det.subtotal == 0, \
               "wrong default subtotal: %s" % det.subtotal
        
        prod = Product()
        prod.price = '12.00'
        det.product = prod
        assert det.subtotal == 0, \
               "wrong subtotal for 0 quantity: %s" % det.subtotal

        det = Detail()
        det.quantity = 10
        det.product = prod
        assert det.subtotal == 120, \
               "didn't get correct subtotal with nonzero quantity"

        det.quantity = 2
        assert det.subtotal == 24, \
               "didn't change subtotal when quantity changed.."     
示例#2
0
    def test_get_subtotal(self):
        """
        subtotal should always be product price * quantity
        """
        det = Detail()
        assert det.subtotal == 0, \
               "wrong default subtotal: %s" % det.subtotal

        prod = Product()
        prod.price = '12.00'
        det.product = prod
        assert det.subtotal == 0, \
               "wrong subtotal for 0 quantity: %s" % det.subtotal

        det = Detail()
        det.quantity = 10
        det.product = prod
        assert det.subtotal == 120, \
               "didn't get correct subtotal with nonzero quantity"

        det.quantity = 2
        assert det.subtotal == 24, \
               "didn't change subtotal when quantity changed.."