예제 #1
0
 def test_raises_exception_when_attribute_is_missing(self):
     scale = Scale(attribute_code='weight')
     p = factories.create_product()
     with self.assertRaises(ValueError):
         scale.weigh_product(p)
예제 #2
0
 def test_uses_default_weight_when_attribute_is_missing(self):
     scale = Scale(attribute_code='weight', default_weight=0.5)
     p = factories.create_product()
     self.assertEqual(0.5, scale.weigh_product(p))
예제 #3
0
 def test_weighs_uses_specified_attribute(self):
     scale = Scale(attribute_code='weight')
     p = factories.create_product(attributes={'weight': '1'})
     self.assertEqual(1, scale.weigh_product(p))
예제 #4
0
 def test_raises_exception_when_attribute_is_missing(self):
     scale = Scale(attribute_code='weight')
     p = factories.create_product()
     with self.assertRaises(ValueError):
         scale.weigh_product(p)
예제 #5
0
 def test_uses_default_weight_when_attribute_is_missing(self):
     scale = Scale(attribute_code='weight', default_weight=0.5)
     p = factories.create_product()
     self.assertEqual(0.5, scale.weigh_product(p))
예제 #6
0
 def test_weighs_uses_specified_attribute(self):
     scale = Scale(attribute_code='weight')
     p = factories.create_product(attributes={'weight': '1'})
     self.assertEqual(1, scale.weigh_product(p))