Skip to content

Commit 94b2359

Browse files
committed
Add stub with nutrition provider tests
1 parent 9a0d3b2 commit 94b2359

8 files changed

+379
-1
lines changed

lib/providers/nutrition.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ class NutritionPlansProvider with ChangeNotifier {
5151
return [..._plans];
5252
}
5353

54+
set ingredients(items) {
55+
_ingredients = items;
56+
}
57+
5458
/// Clears all lists
5559
void clear() {
5660
_plans = [];
@@ -143,7 +147,6 @@ class NutritionPlansProvider with ChangeNotifier {
143147
ingredient.image = image;
144148
}
145149
mealItem.ingredientObj = ingredient;
146-
//mealItem.ingredientObj = await fetchIngredient(mealItem.ingredientId);
147150
mealItems.add(mealItem);
148151
}
149152
meal.mealItems = mealItems;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": 10065,
3+
"code": "0043647440020",
4+
"name": "'Old Times' Orange Fine Cut Marmalade",
5+
"creation_date": "2020-12-20",
6+
"update_date": "2022-08-09",
7+
"energy": 269,
8+
"protein": "0.000",
9+
"carbohydrates": "67.000",
10+
"carbohydrates_sugar": "66.000",
11+
"fat": "0.000",
12+
"fat_saturated": "0.000",
13+
"fibres": null,
14+
"sodium": "0.000",
15+
"license": 5,
16+
"license_author": "Open Food Facts",
17+
"language": 2
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": 58300,
3+
"code": "4071800000992",
4+
"name": "1688 Mehrkorn",
5+
"creation_date": "2020-12-20",
6+
"update_date": "2022-08-09",
7+
"energy": 229,
8+
"protein": "7.680",
9+
"carbohydrates": "35.700",
10+
"carbohydrates_sugar": "2.320",
11+
"fat": "4.820",
12+
"fat_saturated": "0.714",
13+
"fibres": "6.960",
14+
"sodium": "0.000",
15+
"license": 5,
16+
"license_author": "Open Food Facts",
17+
"language": 2
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": 59887,
3+
"code": "4311501354155",
4+
"name": "Baked Beans",
5+
"creation_date": "2020-12-20",
6+
"update_date": "2022-08-09",
7+
"energy": 86,
8+
"protein": "4.400",
9+
"carbohydrates": "11.000",
10+
"carbohydrates_sugar": "5.300",
11+
"fat": "0.100",
12+
"fat_saturated": "0.000",
13+
"fibres": "5.000",
14+
"sodium": "0.480",
15+
"license": 5,
16+
"license_author": "Open Food Facts",
17+
"language": 1
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"count": 3,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 1,
8+
"plan": 1,
9+
"meal": 1,
10+
"ingredient": 59887,
11+
"weight_unit": null,
12+
"datetime": "2022-08-09T20:27:14.064157+02:00",
13+
"amount": "100.00"
14+
},
15+
{
16+
"id": 2,
17+
"plan": 1,
18+
"meal": 1,
19+
"ingredient": 58300,
20+
"weight_unit": null,
21+
"datetime": "2022-08-09T20:27:14.075674+02:00",
22+
"amount": "100.00"
23+
},
24+
{
25+
"id": 3,
26+
"plan": 1,
27+
"meal": 1,
28+
"ingredient": 10065,
29+
"weight_unit": null,
30+
"datetime": "2022-08-09T20:27:14.086133+02:00",
31+
"amount": "200.00"
32+
}
33+
]
34+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"id": 1,
3+
"creation_date": "2022-08-09",
4+
"description": "",
5+
"has_goal_calories": false,
6+
"language": 1
7+
}
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
{
2+
"id": 1,
3+
"language": {
4+
"id": 1,
5+
"short_name": "de",
6+
"full_name": "Deutsch"
7+
},
8+
"creation_date": "2022-08-09",
9+
"description": "",
10+
"get_nutritional_values": {
11+
"total": {
12+
"energy": 853.0,
13+
"protein": 12.08,
14+
"carbohydrates": 180.7,
15+
"carbohydrates_sugar": 139.62,
16+
"fat": 4.92,
17+
"fat_saturated": 0.71,
18+
"fibres": 11.96,
19+
"sodium": 0.48,
20+
"energy_kilojoule": 3568.95
21+
},
22+
"percent": {
23+
"protein": 5.66,
24+
"carbohydrates": 84.74,
25+
"fat": 5.19
26+
},
27+
"per_kg": {
28+
"protein": 0.0,
29+
"carbohydrates": 0.0,
30+
"fat": 0.0
31+
}
32+
},
33+
"meals": [
34+
{
35+
"id": 1,
36+
"plan": 1,
37+
"order": 1,
38+
"time": "08:00:00",
39+
"name": "Frühstück",
40+
"meal_items": [
41+
{
42+
"id": 1,
43+
"meal": 1,
44+
"ingredient": 59887,
45+
"ingredient_obj": {
46+
"id": 59887,
47+
"code": "4311501354155",
48+
"name": "Baked Beans",
49+
"creation_date": "2020-12-20",
50+
"update_date": "2022-08-09",
51+
"energy": 86,
52+
"protein": "4.400",
53+
"carbohydrates": "11.000",
54+
"carbohydrates_sugar": "5.300",
55+
"fat": "0.100",
56+
"fat_saturated": "0.000",
57+
"fibres": "5.000",
58+
"sodium": "0.480",
59+
"license": {
60+
"id": 5,
61+
"full_name": "Open Data Commons Open Database License",
62+
"short_name": "ODbL",
63+
"url": "https://opendatacommons.org/licenses/odbl/"
64+
},
65+
"license_author": "Open Food Facts",
66+
"ingredientweightunit_set": [],
67+
"language": {
68+
"id": 1,
69+
"short_name": "de",
70+
"full_name": "Deutsch"
71+
}
72+
},
73+
"weight_unit": null,
74+
"weight_unit_obj": null,
75+
"image": null,
76+
"order": 1,
77+
"amount": "100.00"
78+
},
79+
{
80+
"id": 2,
81+
"meal": 1,
82+
"ingredient": 58300,
83+
"ingredient_obj": {
84+
"id": 58300,
85+
"code": "4071800000992",
86+
"name": "1688 Mehrkorn",
87+
"creation_date": "2020-12-20",
88+
"update_date": "2022-08-09",
89+
"energy": 229,
90+
"protein": "7.680",
91+
"carbohydrates": "35.700",
92+
"carbohydrates_sugar": "2.320",
93+
"fat": "4.820",
94+
"fat_saturated": "0.714",
95+
"fibres": "6.960",
96+
"sodium": "0.000",
97+
"license": {
98+
"id": 5,
99+
"full_name": "Open Data Commons Open Database License",
100+
"short_name": "ODbL",
101+
"url": "https://opendatacommons.org/licenses/odbl/"
102+
},
103+
"license_author": "Open Food Facts",
104+
"ingredientweightunit_set": [],
105+
"language": {
106+
"id": 2,
107+
"short_name": "en",
108+
"full_name": "English"
109+
}
110+
},
111+
"weight_unit": null,
112+
"weight_unit_obj": null,
113+
"image": {
114+
"id": 3,
115+
"uuid": "778fe5cb-a5d9-42e5-9df2-2a47022b720f",
116+
"ingredient_id": "58300",
117+
"ingredient_uuid": "60e1f479-9af1-4bd4-b2a8-1ebe8974258e",
118+
"image": "http://localhost:8000/media/ingredients/60e1f479-9af1-4bd4-b2a8-1ebe8974258e/778fe5cb-a5d9-42e5-9df2-2a47022b720f.jpg",
119+
"last_update": "2022-08-09T15:31:46.833918+02:00",
120+
"size": 33617,
121+
"source_url": "",
122+
"license": 1,
123+
"license_author": "kiliweb"
124+
},
125+
"order": 1,
126+
"amount": "100.00"
127+
},
128+
{
129+
"id": 3,
130+
"meal": 1,
131+
"ingredient": 10065,
132+
"ingredient_obj": {
133+
"id": 10065,
134+
"code": "0043647440020",
135+
"name": "'Old Times' Orange Fine Cut Marmalade",
136+
"creation_date": "2020-12-20",
137+
"update_date": "2022-08-09",
138+
"energy": 269,
139+
"protein": "0.000",
140+
"carbohydrates": "67.000",
141+
"carbohydrates_sugar": "66.000",
142+
"fat": "0.000",
143+
"fat_saturated": "0.000",
144+
"fibres": null,
145+
"sodium": "0.000",
146+
"license": {
147+
"id": 5,
148+
"full_name": "Open Data Commons Open Database License",
149+
"short_name": "ODbL",
150+
"url": "https://opendatacommons.org/licenses/odbl/"
151+
},
152+
"license_author": "Open Food Facts",
153+
"ingredientweightunit_set": [],
154+
"language": {
155+
"id": 2,
156+
"short_name": "en",
157+
"full_name": "English"
158+
}
159+
},
160+
"weight_unit": null,
161+
"weight_unit_obj": null,
162+
"image": {
163+
"id": 5,
164+
"uuid": "81c07bef-02ea-47ba-a18e-d7388dc2bc01",
165+
"ingredient_id": "10065",
166+
"ingredient_uuid": "b0c47fa4-3898-4705-b8f5-184877d50b78",
167+
"image": "http://localhost:8000/media/ingredients/b0c47fa4-3898-4705-b8f5-184877d50b78/81c07bef-02ea-47ba-a18e-d7388dc2bc01.jpg",
168+
"last_update": "2022-08-09T15:45:58.511169+02:00",
169+
"size": 43397,
170+
"source_url": "",
171+
"license": 1,
172+
"license_author": "tacinte"
173+
},
174+
"order": 1,
175+
"amount": "200.00"
176+
}
177+
],
178+
"get_nutritional_values": {
179+
"energy": 853.0,
180+
"protein": 12.08,
181+
"carbohydrates": 180.7,
182+
"carbohydrates_sugar": 139.62,
183+
"fat": 4.92,
184+
"fat_saturated": 0.71,
185+
"fibres": 11.96,
186+
"sodium": 0.48,
187+
"energy_kilojoule": 3568.95
188+
}
189+
}
190+
]
191+
}

0 commit comments

Comments
 (0)