Skip to content

Commit 445e49f

Browse files
authored
[Mecha Munch Management]: Reformatted Test File & Pulled Data out into Its Own File (#3860)
[no important files changed] * Reformatted test file to test file plus test data file. * Reverted stub to empty. * Updated config in hopes the tests pass.
1 parent bd05215 commit 445e49f

File tree

3 files changed

+419
-143
lines changed

3 files changed

+419
-143
lines changed

exercises/concept/mecha-munch-management/.meta/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
],
1515
"exemplar": [
1616
".meta/exemplar.py"
17+
],
18+
"editor": [
19+
"dict_methods_test_data.py"
1720
]
1821
},
1922
"icon": "gross-store",

exercises/concept/mecha-munch-management/dict_methods_test.py

Lines changed: 23 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import unittest
22
import pytest
33
from collections import OrderedDict
4-
from dict_methods import (add_item,
5-
read_notes,
6-
update_recipes,
7-
sort_entries,
8-
send_to_store,
9-
update_store_inventory)
10-
4+
from dict_methods import (
5+
add_item,
6+
read_notes,
7+
update_recipes,
8+
sort_entries,
9+
send_to_store,
10+
update_store_inventory,
11+
)
12+
13+
from dict_methods_test_data import (
14+
add_item_data,
15+
read_notes_data,
16+
update_recipes_data,
17+
sort_entries_data,
18+
send_to_store_data,
19+
update_store_inventory_data,
20+
)
1121

1222
class MechaMunchManagementTest(unittest.TestCase):
1323

1424
@pytest.mark.task(taskno=1)
1525
def test_add_item(self):
16-
input_data = [
17-
({'Apple': 1, 'Banana': 4 }, ('Apple', 'Banana', 'Orange')),
18-
({'Orange': 1, 'Raspberry': 1, 'Blueberries': 10}, ['Raspberry', 'Blueberries', 'Raspberry']),
19-
({'Broccoli': 1, 'Banana': 1}, ('Broccoli', 'Kiwi', 'Kiwi', 'Kiwi', 'Melon', 'Apple', 'Banana', 'Banana'))
20-
]
21-
22-
output_data = [{'Apple': 2, 'Banana': 5, 'Orange': 1},
23-
{'Orange': 1, 'Raspberry': 3, 'Blueberries': 11},
24-
{'Broccoli': 2, 'Banana': 3, 'Kiwi': 3, 'Melon': 1, 'Apple': 1}]
25-
26-
for variant, (input_data, expected) in enumerate(zip(input_data, output_data), start=1):
26+
for variant, (input_data, expected) in enumerate(add_item_data, start=1):
2727
with self.subTest(f'variation #{variant}', input_data=input_data, expected=expected):
2828
actual_result = add_item(input_data[0], input_data[1])
2929
error_msg= (f'Called add_item({input_data[0]}, {input_data[1]}). '
@@ -34,13 +34,7 @@ def test_add_item(self):
3434

3535
@pytest.mark.task(taskno=2)
3636
def test_read_notes(self):
37-
input_data = [('Apple', "Banana"), ('Orange', 'Raspberry', 'Blueberries'),
38-
['Broccoli', 'Kiwi', 'Melon', 'Apple', 'Banana']]
39-
40-
output_data = [{'Apple': 1, 'Banana': 1}, {'Orange': 1, 'Raspberry': 1, 'Blueberries': 1},
41-
{'Broccoli': 1, 'Kiwi': 1, 'Melon': 1, 'Apple': 1, 'Banana': 1}]
42-
43-
for variant, (input_data, expected) in enumerate(zip(input_data, output_data), start=1):
37+
for variant, (input_data, expected) in enumerate(read_notes_data, start=1):
4438
with self.subTest(f'variation #{variant}', input_data=input_data, expected=expected):
4539
actual_result = read_notes(input_data)
4640
error_msg = (f'Called read_notes({input_data}). '
@@ -51,36 +45,7 @@ def test_read_notes(self):
5145

5246
@pytest.mark.task(taskno=3)
5347
def test_update_recipes(self):
54-
input_data = [
55-
({'Banana Bread' : {'Banana': 1, 'Apple': 1, 'Walnuts': 1, 'Flour': 1, 'Eggs': 2, 'Butter': 1},
56-
'Raspberry Pie' : {'Raspberry': 1, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1}},
57-
(('Banana Bread', {'Banana': 4, 'Walnuts': 2, 'Flour': 1, 'Butter': 1, 'Milk': 2, 'Eggs': 3}),)),
58-
59-
({'Apple Pie': {'Apple': 1, 'Pie Crust': 1, 'Cream Custard': 1},
60-
'Blueberry Pie': {'Blueberries': 1, 'Pie Crust': 1, 'Cream Custard': 1}},
61-
(('Blueberry Pie', {'Blueberries': 2, 'Pie Crust': 1, 'Cream Custard': 1}),
62-
('Apple Pie', {'Apple': 1, 'Pie Crust': 1, 'Cream Custard': 1}))),
63-
64-
({'Banana Bread' : {'Banana': 1, 'Apple': 1, 'Walnuts': 1, 'Flour': 1, 'Eggs': 2, 'Butter': 1},
65-
'Raspberry Pie' : {'Raspberry': 1, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1},
66-
'Pasta Primavera': {'Eggs': 1, 'Carrots': 1, 'Spinach': 2, 'Tomatoes': 3, 'Parmesan': 2, 'Milk': 1, 'Onion': 1}},
67-
(('Raspberry Pie', {'Raspberry': 3, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1, 'Whipped Cream': 2}),
68-
('Pasta Primavera', {'Eggs': 1, 'Mixed Veggies': 2, 'Parmesan': 2, 'Milk': 1, 'Spinach': 1, 'Bread Crumbs': 1}),
69-
('Blueberry Crumble', {'Blueberries': 2, 'Whipped Creme': 2, 'Granola Topping': 2, 'Yogurt': 3})))
70-
]
71-
72-
output_data = [
73-
{'Banana Bread': {'Banana': 4, 'Walnuts': 2, 'Flour': 1, 'Butter': 1, 'Milk': 2, 'Eggs': 3},
74-
'Raspberry Pie': {'Raspberry': 1, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1}},
75-
{'Apple Pie': {'Apple': 1, 'Pie Crust': 1, 'Cream Custard': 1},
76-
'Blueberry Pie': {'Blueberries': 2, 'Pie Crust': 1, 'Cream Custard': 1}},
77-
{'Banana Bread': {'Banana': 1, 'Apple': 1, 'Walnuts': 1, 'Flour': 1, 'Eggs': 2, 'Butter': 1},
78-
'Raspberry Pie': {'Raspberry': 3, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1, 'Whipped Cream': 2},
79-
'Pasta Primavera': {'Eggs': 1, 'Mixed Veggies': 2, 'Parmesan': 2, 'Milk': 1, 'Spinach': 1, 'Bread Crumbs': 1},
80-
'Blueberry Crumble': {'Blueberries': 2, 'Whipped Creme': 2, 'Granola Topping': 2, 'Yogurt': 3}}
81-
]
82-
83-
for variant, (input_data, expected) in enumerate(zip(input_data, output_data), start=1):
48+
for variant, (input_data, expected) in enumerate(update_recipes_data, start=1):
8449
with self.subTest(f'variation #{variant}', input_data=input_data, expected=expected):
8550
actual_result = update_recipes(input_data[0], input_data[1])
8651
error_msg = (f'Called update_recipes({input_data[0]}, {input_data[1]}). '
@@ -91,21 +56,7 @@ def test_update_recipes(self):
9156

9257
@pytest.mark.task(taskno=4)
9358
def test_sort_entries(self):
94-
input_data = [
95-
{'Banana': 4, 'Apple': 2, 'Orange': 1, 'Pear': 12},
96-
{'Apple': 3, 'Orange': 5, 'Banana': 1, 'Avocado': 2},
97-
{'Orange': 3, 'Banana': 2, 'Apple': 1},
98-
{'Apple': 2, 'Raspberry': 2, 'Blueberries': 5, 'Broccoli' : 2, 'Kiwi': 1, 'Melon': 4}
99-
]
100-
101-
output_data = [
102-
{'Apple': 2, 'Banana': 4, 'Orange': 1, 'Pear': 12},
103-
{'Apple': 3, 'Avocado': 2, 'Banana': 1, 'Orange': 5},
104-
{'Apple': 1, 'Banana': 2, 'Orange': 3},
105-
{'Apple' : 2, 'Blueberries': 5, 'Broccoli': 2, 'Kiwi': 1, 'Melon': 4, 'Raspberry': 2}
106-
]
107-
108-
for variant, (input_data, expected) in enumerate(zip(input_data, output_data), start=1):
59+
for variant, (input_data, expected) in enumerate(sort_entries_data, start=1):
10960
with self.subTest(f'variation #{variant}', input_data=input_data, expecred=expected):
11061
actual_result = sort_entries(input_data)
11162
error_msg = (f'Called sort_entries({input_data}). '
@@ -119,49 +70,7 @@ def test_sort_entries(self):
11970

12071
@pytest.mark.task(taskno=5)
12172
def test_send_to_store(self):
122-
input_data = [
123-
({'Banana': 3, 'Apple': 2, 'Orange': 1, 'Milk': 2},
124-
{'Banana': ['Aisle 5', False], 'Apple': ['Aisle 4', False],
125-
'Orange': ['Aisle 4', False], 'Milk': ['Aisle 2', True]}),
126-
127-
({'Kiwi': 3, 'Juice': 5, 'Yoghurt': 2, 'Milk': 5},
128-
{'Kiwi': ['Aisle 6', False], 'Juice': ['Aisle 5', False],
129-
'Yoghurt': ['Aisle 2', True], 'Milk': ['Aisle 2', True]}),
130-
131-
({'Apple': 2, 'Raspberry': 2, 'Blueberries': 5,
132-
'Broccoli': 2, 'Kiwi': 1, 'Melon': 4},
133-
134-
{'Apple': ['Aisle 1', False], 'Raspberry': ['Aisle 6', False],
135-
'Blueberries': ['Aisle 6', False], 'Broccoli': ['Aisle 3', False],
136-
'Kiwi': ['Aisle 6', False], 'Melon': ['Aisle 6', False]}),
137-
138-
({'Orange': 1},
139-
{'Banana': ['Aisle 5', False], 'Apple': ['Aisle 4', False],
140-
'Orange': ['Aisle 4', False], 'Milk': ['Aisle 2', True]}),
141-
142-
({'Banana': 3, 'Apple': 2, 'Orange': 1},
143-
{'Banana': ['Aisle 5', False], 'Apple': ['Aisle 4', False],
144-
'Orange': ['Aisle 4', False], 'Milk': ['Aisle 2', True]}),
145-
]
146-
147-
output_data = [
148-
{'Orange': [1, 'Aisle 4', False], 'Milk': [2, 'Aisle 2', True],
149-
'Banana': [3, 'Aisle 5', False], 'Apple': [2, 'Aisle 4', False]},
150-
151-
{'Yoghurt': [2, 'Aisle 2', True], 'Milk': [5, 'Aisle 2', True],
152-
'Kiwi': [3, 'Aisle 6', False], 'Juice': [5, 'Aisle 5', False]},
153-
154-
{'Raspberry': [2, 'Aisle 6', False], 'Melon': [4, 'Aisle 6', False],
155-
'Kiwi': [1, 'Aisle 6', False], 'Broccoli': [2, 'Aisle 3', False],
156-
'Blueberries': [5, 'Aisle 6', False], 'Apple': [2, 'Aisle 1', False]},
157-
158-
{'Orange': [1, 'Aisle 4', False]},
159-
160-
{'Orange': [1, 'Aisle 4', False], 'Banana': [3, 'Aisle 5', False],
161-
'Apple': [2, 'Aisle 4', False]},
162-
]
163-
164-
for variant, (input_data, expected) in enumerate(zip(input_data, output_data), start=1):
73+
for variant, (input_data, expected) in enumerate(send_to_store_data, start=1):
16574
with self.subTest(f'variation #{variant}', input_data=input_data, expected=expected):
16675
actual_result = send_to_store(input_data[0], input_data[1])
16776
error_msg = (f'Called send_to_store({input_data[0]}, {input_data[1]}). '
@@ -175,36 +84,7 @@ def test_send_to_store(self):
17584

17685
@pytest.mark.task(taskno=6)
17786
def test_update_store_inventory(self):
178-
input_data = [
179-
({'Orange': [1, 'Aisle 4', False], 'Milk': [2, 'Aisle 2', True],
180-
'Banana': [3, 'Aisle 5', False], 'Apple': [2, 'Aisle 4', False]},
181-
{'Banana': [15, 'Aisle 5', False], 'Apple': [12, 'Aisle 4', False],
182-
'Orange': [1, 'Aisle 4', False], 'Milk': [4, 'Aisle 2', True]}),
183-
184-
({'Kiwi': [3, 'Aisle 6', False]},{'Kiwi': [3, 'Aisle 6', False], 'Juice': [5, 'Aisle 5', False],
185-
'Yoghurt': [2, 'Aisle 2', True], 'Milk': [5, 'Aisle 2', True]}),
186-
187-
({'Kiwi': [1, 'Aisle 6', False], 'Melon': [4, 'Aisle 6', False], 'Apple': [2, 'Aisle 1', False],
188-
'Raspberry': [2, 'Aisle 6', False], 'Blueberries': [5, 'Aisle 6', False],
189-
'Broccoli': [1, 'Aisle 3', False]},
190-
{'Apple': [2, 'Aisle 1', False], 'Raspberry': [5, 'Aisle 6', False],
191-
'Blueberries': [10, 'Aisle 6', False], 'Broccoli': [4, 'Aisle 3', False],
192-
'Kiwi': [1, 'Aisle 6', False], 'Melon': [8, 'Aisle 6', False]})
193-
]
194-
195-
output_data = [
196-
{'Banana': [12, 'Aisle 5', False], 'Apple': [10, 'Aisle 4', False],
197-
'Orange': ['Out of Stock', 'Aisle 4', False], 'Milk': [2, 'Aisle 2', True]},
198-
199-
{'Juice': [5, 'Aisle 5', False], 'Yoghurt': [2, 'Aisle 2', True],
200-
'Milk': [5, 'Aisle 2', True], 'Kiwi': ["Out of Stock", 'Aisle 6', False]},
201-
202-
{'Kiwi': ['Out of Stock', 'Aisle 6', False], 'Melon': [4, 'Aisle 6', False],
203-
'Apple': ['Out of Stock', 'Aisle 1', False], 'Raspberry': [3, 'Aisle 6', False],
204-
'Blueberries': [5, 'Aisle 6', False], 'Broccoli': [3, 'Aisle 3', False]}
205-
]
206-
207-
for variant, (input_data, expected) in enumerate(zip(input_data, output_data), start=1):
87+
for variant, (input_data, expected) in enumerate(update_store_inventory_data, start=1):
20888
with self.subTest(f'variation #{variant}', input_data=input_data, expected=expected):
20989
actual_result = update_store_inventory(input_data[0], input_data[1])
21090
error_msg = (f'Called update_store_inventory({input_data[0]}, {input_data[1]}). '

0 commit comments

Comments
 (0)