<commit_before>from django.test import TestCase
from core.models import Food, Unit, Equivalence, FoodNutritionInfo

class FoodNutritionTest (TestCase):
    """Test operations related to FoodNutritionInfo.
    """
    fixtures = ['test_unit', 'test_food', 'test_equivalence']

    def test_normalize_nutrition_info(self):
        """Normalize FoodNutritionInfo.
        """
        gram = Unit.objects.get(name='gram')
        butter = Food.objects.get(name='butter')
        butter_nutrition = FoodNutritionInfo(
            food         = butter,
            quantity     = 14.0,
            unit         = gram,
            calories     = 100,
            fat_calories = 100,<commit_msg>New test: test_has_nutrition_info<commit_after>from django.test import TestCase
from core.models import Food, Unit, Equivalence, FoodNutritionInfo

class FoodNutritionTest (TestCase):
    """Test operations related to FoodNutritionInfo.
    """
    fixtures = ['test_unit', 'test_food', 'test_equivalence']

    def test_has_nutrition_info(self):
        """Check whether a Food has a NutritionInfo.
        """
        butter = Food.objects.get(name='butter')
        self.assertFalse(butter.has_nutrition_info())
        # Add nutrition
        gram = Unit.objects.get(name='gram')
        butter_nutrition = FoodNutritionInfo(
            food         = butter,
            quantity     = 14.0,
            unit         = gram,
            calories     = 100,
            fat_calories = 100,
            fat          = 11,
            carb         = 0,
            sodium       = 90,
            protein      = 0,
            cholesterol  = 30,
        )
        butter_nutrition.save()
        self.assertTrue(butter.has_nutrition_info())


    def test_normalize_nutrition_info(self):
        """Normalize FoodNutritionInfo.
        """
        gram = Unit.objects.get(name='gram')
        butter = Food.objects.get(name='butter')
        butter_nutrition = FoodNutritionInfo(
            food         = butter,
            quantity     = 14.0,
            unit         = gram,
            calories     = 100,
            fat_calories = 100,
{'fraction_non_alphanumeric': 0.09508196721311475, 'fraction_numerical': 0.01639344262295082, 'mean_word_length': 1.898236092265943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6401827', 'n_tokens_mistral': 633, 'n_tokens_neox': 590, 'n_words': 127}