Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed May 23, 2024
1 parent 99f51b4 commit a979d4c
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions wger/nutrition/tests/test_ingredient.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,24 +463,21 @@ class IngredientModelTestCase(WgerTestCase):
def setUp(self):
super().setUp()
self.off_response = {
'status': OFF_SEARCH_PRODUCT_FOUND,
'product': {
'code': '1234',
'lang': 'de',
'product_name': 'Foo with chocolate',
'generic_name': 'Foo with chocolate, 250g package',
'brands': 'The bar company',
'editors_tags': ['open food facts', 'MrX'],
'nutriments': {
'energy-kcal_100g': 120,
'proteins_100g': 10,
'carbohydrates_100g': 20,
'sugars_100g': 30,
'fat_100g': 40,
'saturated-fat_100g': 11,
'sodium_100g': 5,
'fiber_100g': None,
},
'code': '1234',
'lang': 'de',
'product_name': 'Foo with chocolate',
'generic_name': 'Foo with chocolate, 250g package',
'brands': 'The bar company',
'editors_tags': ['open food facts', 'MrX'],
'nutriments': {
'energy-kcal_100g': 120,
'proteins_100g': 10,
'carbohydrates_100g': 20,
'sugars_100g': 30,
'fat_100g': 40,
'saturated-fat_100g': 11,
'sodium_100g': 5,
'fiber_100g': None,
},
}

Expand Down Expand Up @@ -512,7 +509,7 @@ def test_fetch_from_off_success_long_name(self, mock_api):
"""
Tests creating an ingredient from OFF - name gets truncated
"""
self.off_response['product']['product_name'] = """
self.off_response['product_name'] = """
The Shiba Inu (柴犬, Japanese: [ɕiba inɯ]) is a breed of hunting dog from Japan. A
small-to-medium breed, it is the smallest of the six original and distinct spitz
breeds of dog native to Japan.[1] Its name literally translates to "brushwood dog",
Expand All @@ -527,7 +524,7 @@ def test_fetch_from_off_key_missing_1(self, mock_api):
"""
Tests creating an ingredient from OFF - missing key in nutriments
"""
del self.off_response['product']['nutriments']['energy-kcal_100g']
del self.off_response['nutriments']['energy-kcal_100g']
mock_api.return_value = self.off_response

ingredient = Ingredient.fetch_ingredient_from_off('1234')
Expand All @@ -538,7 +535,7 @@ def test_fetch_from_off_key_missing_2(self, mock_api):
"""
Tests creating an ingredient from OFF - missing name
"""
del self.off_response['product']['product_name']
del self.off_response['product_name']
mock_api.return_value = self.off_response

ingredient = Ingredient.fetch_ingredient_from_off('1234')
Expand Down

0 comments on commit a979d4c

Please sign in to comment.