Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Seed support for plural units #3933

Merged
45 changes: 42 additions & 3 deletions mealie/repos/seed/resources/units/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,102 +1,141 @@
{
"teaspoon": {
"name": "teaspoon",
"plural_name": "teaspoons",
"description": "",
"abbreviation": "tsp"
},
"tablespoon": {
"name": "tablespoon",
"plural_name": "tablespoons",
"description": "",
"abbreviation": "tbsp"
},
"cup": {
"name": "cup",
"plural_name": "cups",
"description": "",
"abbreviation": "cup"
"abbreviation": "c"
},
"fluid-ounce": {
"name": "fluid ounce",
"plural_name": "fluid ounces",
"description": "",
"abbreviation": "fl oz"
},
"pint": {
"name": "pint",
"plural_name": "pints",
"description": "",
"abbreviation": "pt"
},
"quart": {
"name": "quart",
"plural_name": "quarts",
"description": "",
"abbreviation": "qt"
},
"gallon": {
"name": "gallon",
"plural_name": "gallons",
"description": "",
"abbreviation": "gal"
},
"milliliter": {
"name": "milliliter",
"plural_name": "milliliters",
"description": "",
"abbreviation": "ml"
},
"liter": {
"name": "liter",
"plural_name": "liters",
"description": "",
"abbreviation": "l"
},
"pound": {
"name": "pound",
"plural_name": "pounds",
"description": "",
"abbreviation": "lb"
"abbreviation": "lb",
"plural_abbreviation": "lbs"
},
"ounce": {
"name": "ounce",
"plural_name": "ounces",
"description": "",
"abbreviation": "oz"
},
"gram": {
"name": "gram",
"plural_name": "grams",
"description": "",
"abbreviation": "g"
},
"kilogram": {
"name": "kilogram",
"plural_name": "kilograms",
"description": "",
"abbreviation": "kg"
},
"milligram": {
"name": "milligram",
"plural_name": "milligrams",
"description": "",
"abbreviation": "mg"
},
"splash": {
"name": "splash",
"plural_name": "splashes",
"description": "",
"abbreviation": ""
},
"dash": {
"name": "dash",
"plural_name": "dashes",
"description": "",
"abbreviation": ""
},
"serving": {
"name": "serving",
"plural_name": "servings",
"description": "",
"abbreviation": ""
},
"head": {
"name": "head",
"plural_name": "heads",
"description": "",
"abbreviation": ""
},
"clove": {
"name": "clove",
"plural_name": "cloves",
"description": "",
"abbreviation": ""
},
"can": {
"name": "can",
"plural_name": "cans",
"description": "",
"abbreviation": ""
},
"bunch": {
"name": "bunch",
"plural_name": "bunches",
"description": "",
"abbreviation": ""
},
"pack": {
"name": "pack",
"plural_name": "packs",
"description": "",
"abbreviation": ""
},
"pinch": {
"name": "pinch",
"plural_name": "pinches",
"description": "",
"abbreviation": ""
}
}
}
2 changes: 2 additions & 0 deletions mealie/repos/seed/seeders.py
Original file line number Diff line number Diff line change
@@ -60,8 +60,10 @@ def load_data(self, locale: str | None = None) -> Generator[SaveIngredientUnit,
yield SaveIngredientUnit(
group_id=self.group_id,
name=unit["name"],
plural_name=unit.get("plural_name"),
description=unit["description"],
abbreviation=unit["abbreviation"],
plural_abbreviation=unit.get("plural_abbreviation"),
)

def seed(self, locale: str | None = None) -> None:
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ def test_seed_foods(api_client: TestClient, unique_user: TestUser, database: All


def test_seed_units(api_client: TestClient, unique_user: TestUser, database: AllRepositories):
CREATED_UNITS = 20
CREATED_UNITS = 23

# Check that the foods was created
units = database.ingredient_units.by_group(unique_user.group_id).get_all()