コード例 #1
0
ファイル: add_mult.py プロジェクト: mpuig/gustosity
    def test_nutrition_info_set_equal(self):
        """Set one NutritionInfo equal to another.
        """
        nutrient_a = NutritionInfo(
            calories=50,
            fat_calories=20,
            fat=5,
            carb=3,
            sodium=10,
            protein=0,
            cholesterol=40,
        )

        nutrient_b = NutritionInfo(
            calories=40,
            fat_calories=30,
            fat=10,
            carb=0,
            sodium=30,
            protein=0,
            cholesterol=5,
        )

        nutrient_b.set_equal(nutrient_a)
        expected_total = NutritionInfo(
            calories=50,
            fat_calories=20,
            fat=5,
            carb=3,
            sodium=10,
            protein=0,
            cholesterol=40,
        )
        self.assertTrue(nutrient_b.is_equal(expected_total))
コード例 #2
0
ファイル: formatting.py プロジェクト: mpuig/gustosity
    def test_nutrition_info_string(self):
        """Format NutritionInfo as a string.
        """
        nutrient = NutritionInfo(
            calories     = 50,
            fat_calories = 20,
            fat          = 5,
            carb         = 3,
            sodium       = 10,
            protein      = 0,
            cholesterol  = 40,
        )
        self.assertEqual(str(nutrient), '50 calories')

        self.assertEqual(nutrient.full_string(),
            "50 calories (20 from fat) 5g fat, 3g carbs, 10mg sodium, 0g protein, 40mg cholesterol")
コード例 #3
0
ファイル: other.py プロジェクト: mpuig/gustosity
    def test_nutrition_info_is_empty(self):
        """Check if NutritionInfo is empty.
        """
        empty_nutrient = NutritionInfo(
            calories     = 0,
            fat_calories = 0,
            fat          = 0,
            carb         = 0,
            sodium       = 0,
            protein      = 0,
            cholesterol  = 0,
        )
        self.assertTrue(empty_nutrient.is_empty())

        non_empty_nutrient = NutritionInfo(
            calories     = 0,
            fat_calories = 0,
            fat          = 0,
            carb         = 0,
            sodium       = 10,
            protein      = 0,
            cholesterol  = 0,
        )
        self.assertFalse(non_empty_nutrient.is_empty())