Ejemplo n.º 1
0
def test_calculate_params():
    unit1 = "g"
    unit2 = "piece"
    value_to_calc = Decimal(10.5)
    weight1 = Decimal(50)
    weight2 = Decimal(2)
    weight_in_pcs = Decimal(100)
    assert calculate_params(unit1, value_to_calc, weight1, weight_in_pcs) == 5.25
    assert calculate_params(unit2, value_to_calc, weight2, weight_in_pcs) == 21
Ejemplo n.º 2
0
 def proteins(self) -> float:
     proteins = calculate_params(
         self.unit,
         self.product.proteins_per_100,
         self.weight,
         self.product.weight_of_pcs,
     )
     return proteins
Ejemplo n.º 3
0
 def calories(self) -> float:
     calories = calculate_params(
         self.unit,
         self.product.calories_per_100,
         self.weight,
         self.product.weight_of_pcs,
     )
     return calories
Ejemplo n.º 4
0
 def fats(self) -> float:
     fats = calculate_params(
         self.unit,
         self.product.fats_per_100,
         self.weight,
         self.product.weight_of_pcs,
     )
     return fats