本文整理汇总了Python中oscar.apps.shipping.Scales.weigh_product方法的典型用法代码示例。如果您正苦于以下问题:Python Scales.weigh_product方法的具体用法?Python Scales.weigh_product怎么用?Python Scales.weigh_product使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oscar.apps.shipping.Scales
的用法示例。
在下文中一共展示了Scales.weigh_product方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_raises_exception_when_attribute_is_missing
# 需要导入模块: from oscar.apps.shipping import Scales [as 别名]
# 或者: from oscar.apps.shipping.Scales import weigh_product [as 别名]
def test_raises_exception_when_attribute_is_missing(self):
scales = Scales(attribute_code='weight')
p = factories.create_product()
with self.assertRaises(ValueError):
scales.weigh_product(p)
示例2: test_uses_default_weight_when_attribute_is_missing
# 需要导入模块: from oscar.apps.shipping import Scales [as 别名]
# 或者: from oscar.apps.shipping.Scales import weigh_product [as 别名]
def test_uses_default_weight_when_attribute_is_missing(self):
scales = Scales(attribute_code='weight', default_weight=0.5)
p = factories.create_product()
self.assertEqual(0.5, scales.weigh_product(p))
示例3: test_weighs_uses_specified_attribute
# 需要导入模块: from oscar.apps.shipping import Scales [as 别名]
# 或者: from oscar.apps.shipping.Scales import weigh_product [as 别名]
def test_weighs_uses_specified_attribute(self):
scales = Scales(attribute_code='weight')
p = factories.create_product(attributes={'weight': '1'})
self.assertEqual(1, scales.weigh_product(p))
示例4: test_simple_weight_calculation
# 需要导入模块: from oscar.apps.shipping import Scales [as 别名]
# 或者: from oscar.apps.shipping.Scales import weigh_product [as 别名]
def test_simple_weight_calculation(self):
scales = Scales(attribute_code='weight')
p = create_product(attributes={'weight': 1})
self.assertEqual(1, scales.weigh_product(p))
示例5: test_exception_is_raised_when_attribute_is_missing
# 需要导入模块: from oscar.apps.shipping import Scales [as 别名]
# 或者: from oscar.apps.shipping.Scales import weigh_product [as 别名]
def test_exception_is_raised_when_attribute_is_missing(self):
scales = Scales(attribute_code="weight")
p = create_product()
with self.assertRaises(ValueError):
scales.weigh_product(p)
示例6: test_default_weight_is_used_when_attribute_is_missing
# 需要导入模块: from oscar.apps.shipping import Scales [as 别名]
# 或者: from oscar.apps.shipping.Scales import weigh_product [as 别名]
def test_default_weight_is_used_when_attribute_is_missing(self):
scales = Scales(attribute_code="weight", default_weight=0.5)
p = create_product()
self.assertEqual(0.5, scales.weigh_product(p))