mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-01 04:36:12 -04:00
chore: upgrade pre-commit hooks (#1735)
* change pep585 hook to pyupgrade * run pyupgrade + cleanup lint errors
This commit is contained in:
parent
e516a2e801
commit
a8f0fb14a7
@ -10,10 +10,10 @@ repos:
|
|||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
exclude: ^tests/data/
|
exclude: ^tests/data/
|
||||||
- repo: https://github.com/sondrelg/pep585-upgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: "v1.0.1" # Use the sha / tag you want to point at
|
rev: v3.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: upgrade-type-hints
|
- id: pyupgrade
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: 5.10.1
|
rev: 5.10.1
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -13,7 +13,7 @@ def determine_secrets(data_dir: Path, production: bool) -> str:
|
|||||||
|
|
||||||
secrets_file = data_dir.joinpath(".secret")
|
secrets_file = data_dir.joinpath(".secret")
|
||||||
if secrets_file.is_file():
|
if secrets_file.is_file():
|
||||||
with open(secrets_file, "r") as f:
|
with open(secrets_file) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
else:
|
else:
|
||||||
data_dir.mkdir(parents=True, exist_ok=True)
|
data_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
@ -57,7 +57,7 @@ def clean_recipe_folders(root_dir: Path, dry_run: bool) -> int:
|
|||||||
|
|
||||||
def tail_log(log_file: Path, n: int) -> list[str]:
|
def tail_log(log_file: Path, n: int) -> list[str]:
|
||||||
try:
|
try:
|
||||||
with open(log_file, "r") as f:
|
with open(log_file) as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return ["no log file found"]
|
return ["no log file found"]
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, Union
|
|
||||||
|
|
||||||
from pydantic import UUID4
|
from pydantic import UUID4
|
||||||
from pydantic.utils import GetterDict
|
from pydantic.utils import GetterDict
|
||||||
@ -33,19 +32,19 @@ class ShoppingListItemCreate(MealieModel):
|
|||||||
|
|
||||||
is_food: bool = False
|
is_food: bool = False
|
||||||
|
|
||||||
note: Optional[str] = ""
|
note: str | None = ""
|
||||||
quantity: float = 1
|
quantity: float = 1
|
||||||
unit_id: UUID4 = None
|
unit_id: UUID4 = None
|
||||||
unit: Optional[IngredientUnit]
|
unit: IngredientUnit | None
|
||||||
food_id: UUID4 = None
|
food_id: UUID4 = None
|
||||||
food: Optional[IngredientFood]
|
food: IngredientFood | None
|
||||||
|
|
||||||
label_id: Optional[UUID4] = None
|
label_id: UUID4 | None = None
|
||||||
recipe_references: list[ShoppingListItemRecipeRef] = []
|
recipe_references: list[ShoppingListItemRecipeRef] = []
|
||||||
extras: Optional[dict] = {}
|
extras: dict | None = {}
|
||||||
|
|
||||||
created_at: Optional[datetime]
|
created_at: datetime | None
|
||||||
update_at: Optional[datetime]
|
update_at: datetime | None
|
||||||
|
|
||||||
|
|
||||||
class ShoppingListItemUpdate(ShoppingListItemCreate):
|
class ShoppingListItemUpdate(ShoppingListItemCreate):
|
||||||
@ -53,8 +52,8 @@ class ShoppingListItemUpdate(ShoppingListItemCreate):
|
|||||||
|
|
||||||
|
|
||||||
class ShoppingListItemOut(ShoppingListItemUpdate):
|
class ShoppingListItemOut(ShoppingListItemUpdate):
|
||||||
label: Optional[MultiPurposeLabelSummary]
|
label: MultiPurposeLabelSummary | None
|
||||||
recipe_references: list[Union[ShoppingListItemRecipeRef, ShoppingListItemRecipeRefOut]] = []
|
recipe_references: list[ShoppingListItemRecipeRef | ShoppingListItemRecipeRefOut] = []
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
@ -69,10 +68,10 @@ class ShoppingListItemOut(ShoppingListItemUpdate):
|
|||||||
|
|
||||||
class ShoppingListCreate(MealieModel):
|
class ShoppingListCreate(MealieModel):
|
||||||
name: str = None
|
name: str = None
|
||||||
extras: Optional[dict] = {}
|
extras: dict | None = {}
|
||||||
|
|
||||||
created_at: Optional[datetime]
|
created_at: datetime | None
|
||||||
update_at: Optional[datetime]
|
update_at: datetime | None
|
||||||
|
|
||||||
|
|
||||||
class ShoppingListRecipeRefOut(MealieModel):
|
class ShoppingListRecipeRefOut(MealieModel):
|
||||||
@ -119,8 +118,8 @@ class ShoppingListOut(ShoppingListUpdate):
|
|||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
||||||
|
|
||||||
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary
|
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary # noqa: E402
|
||||||
from mealie.schema.recipe.recipe import RecipeSummary
|
from mealie.schema.recipe.recipe import RecipeSummary # noqa: E402
|
||||||
|
|
||||||
ShoppingListRecipeRefOut.update_forward_refs()
|
ShoppingListRecipeRefOut.update_forward_refs()
|
||||||
ShoppingListItemOut.update_forward_refs()
|
ShoppingListItemOut.update_forward_refs()
|
||||||
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from pydantic import UUID4, BaseModel, Field, validator
|
from pydantic import UUID4, BaseModel, Field, validator
|
||||||
@ -69,35 +69,35 @@ class CreateRecipe(MealieModel):
|
|||||||
|
|
||||||
|
|
||||||
class RecipeSummary(MealieModel):
|
class RecipeSummary(MealieModel):
|
||||||
id: Optional[UUID4]
|
id: UUID4 | None
|
||||||
|
|
||||||
user_id: UUID4 = Field(default_factory=uuid4)
|
user_id: UUID4 = Field(default_factory=uuid4)
|
||||||
group_id: UUID4 = Field(default_factory=uuid4)
|
group_id: UUID4 = Field(default_factory=uuid4)
|
||||||
|
|
||||||
name: Optional[str]
|
name: str | None
|
||||||
slug: str = ""
|
slug: str = ""
|
||||||
image: Optional[Any]
|
image: Any | None
|
||||||
recipe_yield: Optional[str]
|
recipe_yield: str | None
|
||||||
|
|
||||||
total_time: Optional[str] = None
|
total_time: str | None = None
|
||||||
prep_time: Optional[str] = None
|
prep_time: str | None = None
|
||||||
cook_time: Optional[str] = None
|
cook_time: str | None = None
|
||||||
perform_time: Optional[str] = None
|
perform_time: str | None = None
|
||||||
|
|
||||||
description: Optional[str] = ""
|
description: str | None = ""
|
||||||
recipe_category: Optional[list[RecipeCategory]] = []
|
recipe_category: list[RecipeCategory] | None = []
|
||||||
tags: Optional[list[RecipeTag]] = []
|
tags: list[RecipeTag] | None = []
|
||||||
tools: list[RecipeTool] = []
|
tools: list[RecipeTool] = []
|
||||||
rating: Optional[int]
|
rating: int | None
|
||||||
org_url: Optional[str] = Field(None, alias="orgURL")
|
org_url: str | None = Field(None, alias="orgURL")
|
||||||
|
|
||||||
recipe_ingredient: Optional[list[RecipeIngredient]] = []
|
recipe_ingredient: list[RecipeIngredient] | None = []
|
||||||
|
|
||||||
date_added: Optional[datetime.date]
|
date_added: datetime.date | None
|
||||||
date_updated: Optional[datetime.datetime]
|
date_updated: datetime.datetime | None
|
||||||
|
|
||||||
created_at: Optional[datetime.datetime]
|
created_at: datetime.datetime | None
|
||||||
update_at: Optional[datetime.datetime]
|
update_at: datetime.datetime | None
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
@ -137,17 +137,17 @@ class RecipePagination(PaginationBase):
|
|||||||
|
|
||||||
class Recipe(RecipeSummary):
|
class Recipe(RecipeSummary):
|
||||||
recipe_ingredient: list[RecipeIngredient] = []
|
recipe_ingredient: list[RecipeIngredient] = []
|
||||||
recipe_instructions: Optional[list[RecipeStep]] = []
|
recipe_instructions: list[RecipeStep] | None = []
|
||||||
nutrition: Optional[Nutrition]
|
nutrition: Nutrition | None
|
||||||
|
|
||||||
# Mealie Specific
|
# Mealie Specific
|
||||||
settings: Optional[RecipeSettings] = None
|
settings: RecipeSettings | None = None
|
||||||
assets: Optional[list[RecipeAsset]] = []
|
assets: list[RecipeAsset] | None = []
|
||||||
notes: Optional[list[RecipeNote]] = []
|
notes: list[RecipeNote] | None = []
|
||||||
extras: Optional[dict] = {}
|
extras: dict | None = {}
|
||||||
is_ocr_recipe: Optional[bool] = False
|
is_ocr_recipe: bool | None = False
|
||||||
|
|
||||||
comments: Optional[list[RecipeCommentOut]] = []
|
comments: list[RecipeCommentOut] | None = []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def directory_from_id(recipe_id: UUID4 | str) -> Path:
|
def directory_from_id(recipe_id: UUID4 | str) -> Path:
|
||||||
@ -205,7 +205,7 @@ class Recipe(RecipeSummary):
|
|||||||
return recipe_ingredient
|
return recipe_ingredient
|
||||||
|
|
||||||
|
|
||||||
from mealie.schema.recipe.recipe_ingredient import RecipeIngredient
|
from mealie.schema.recipe.recipe_ingredient import RecipeIngredient # noqa: E402
|
||||||
|
|
||||||
RecipeSummary.update_forward_refs()
|
RecipeSummary.update_forward_refs()
|
||||||
Recipe.update_forward_refs()
|
Recipe.update_forward_refs()
|
||||||
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import enum
|
import enum
|
||||||
from typing import Optional, Union
|
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
from pydantic import UUID4, Field, validator
|
from pydantic import UUID4, Field, validator
|
||||||
@ -17,11 +16,11 @@ from mealie.schema.response.pagination import PaginationBase
|
|||||||
class UnitFoodBase(MealieModel):
|
class UnitFoodBase(MealieModel):
|
||||||
name: str
|
name: str
|
||||||
description: str = ""
|
description: str = ""
|
||||||
extras: Optional[dict] = {}
|
extras: dict | None = {}
|
||||||
|
|
||||||
|
|
||||||
class CreateIngredientFood(UnitFoodBase):
|
class CreateIngredientFood(UnitFoodBase):
|
||||||
label_id: Optional[UUID4] = None
|
label_id: UUID4 | None = None
|
||||||
|
|
||||||
|
|
||||||
class SaveIngredientFood(CreateIngredientFood):
|
class SaveIngredientFood(CreateIngredientFood):
|
||||||
@ -30,9 +29,9 @@ class SaveIngredientFood(CreateIngredientFood):
|
|||||||
|
|
||||||
class IngredientFood(CreateIngredientFood):
|
class IngredientFood(CreateIngredientFood):
|
||||||
id: UUID4
|
id: UUID4
|
||||||
label: Optional[MultiPurposeLabelSummary] = None
|
label: MultiPurposeLabelSummary | None = None
|
||||||
created_at: Optional[datetime.datetime]
|
created_at: datetime.datetime | None
|
||||||
update_at: Optional[datetime.datetime]
|
update_at: datetime.datetime | None
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
@ -61,8 +60,8 @@ class SaveIngredientUnit(CreateIngredientUnit):
|
|||||||
|
|
||||||
class IngredientUnit(CreateIngredientUnit):
|
class IngredientUnit(CreateIngredientUnit):
|
||||||
id: UUID4
|
id: UUID4
|
||||||
created_at: Optional[datetime.datetime]
|
created_at: datetime.datetime | None
|
||||||
update_at: Optional[datetime.datetime]
|
update_at: datetime.datetime | None
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
@ -73,13 +72,13 @@ class IngredientUnitPagination(PaginationBase):
|
|||||||
|
|
||||||
|
|
||||||
class RecipeIngredient(MealieModel):
|
class RecipeIngredient(MealieModel):
|
||||||
title: Optional[str]
|
title: str | None
|
||||||
note: Optional[str]
|
note: str | None
|
||||||
unit: Optional[Union[IngredientUnit, CreateIngredientUnit]]
|
unit: IngredientUnit | CreateIngredientUnit | None
|
||||||
food: Optional[Union[IngredientFood, CreateIngredientFood]]
|
food: IngredientFood | CreateIngredientFood | None
|
||||||
disable_amount: bool = True
|
disable_amount: bool = True
|
||||||
quantity: NoneFloat = 1
|
quantity: NoneFloat = 1
|
||||||
original_text: Optional[str]
|
original_text: str | None
|
||||||
|
|
||||||
# Ref is used as a way to distinguish between an individual ingredient on the frontend
|
# Ref is used as a way to distinguish between an individual ingredient on the frontend
|
||||||
# It is required for the reorder and section titles to function properly because of how
|
# It is required for the reorder and section titles to function properly because of how
|
||||||
@ -123,7 +122,7 @@ class IngredientConfidence(MealieModel):
|
|||||||
|
|
||||||
|
|
||||||
class ParsedIngredient(MealieModel):
|
class ParsedIngredient(MealieModel):
|
||||||
input: Optional[str]
|
input: str | None
|
||||||
confidence: IngredientConfidence = IngredientConfidence()
|
confidence: IngredientConfidence = IngredientConfidence()
|
||||||
ingredient: RecipeIngredient
|
ingredient: RecipeIngredient
|
||||||
|
|
||||||
@ -153,6 +152,6 @@ class MergeUnit(MealieModel):
|
|||||||
to_unit: UUID4
|
to_unit: UUID4
|
||||||
|
|
||||||
|
|
||||||
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary
|
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary # noqa: E402
|
||||||
|
|
||||||
IngredientFood.update_forward_refs()
|
IngredientFood.update_forward_refs()
|
||||||
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, TypeVar, Union, cast
|
from typing import Any, TypeVar, cast
|
||||||
|
|
||||||
from dateutil import parser as date_parser
|
from dateutil import parser as date_parser
|
||||||
from dateutil.parser import ParserError
|
from dateutil.parser import ParserError
|
||||||
@ -209,13 +209,13 @@ class QueryFilter:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_base_components_into_filter_components(
|
def _parse_base_components_into_filter_components(
|
||||||
base_components: list[str],
|
base_components: list[str],
|
||||||
) -> list[Union[str, QueryFilterComponent, LogicalOperator]]:
|
) -> list[str | QueryFilterComponent | LogicalOperator]:
|
||||||
"""Walk through base components and construct filter collections"""
|
"""Walk through base components and construct filter collections"""
|
||||||
relational_operators = [op.value for op in RelationalOperator]
|
relational_operators = [op.value for op in RelationalOperator]
|
||||||
logical_operators = [op.value for op in LogicalOperator]
|
logical_operators = [op.value for op in LogicalOperator]
|
||||||
|
|
||||||
# parse QueryFilterComponents and logical operators
|
# parse QueryFilterComponents and logical operators
|
||||||
components: list[Union[str, QueryFilterComponent, LogicalOperator]] = []
|
components: list[str | QueryFilterComponent | LogicalOperator] = []
|
||||||
for i, base_component in enumerate(base_components):
|
for i, base_component in enumerate(base_components):
|
||||||
if base_component in QueryFilter.seps:
|
if base_component in QueryFilter.seps:
|
||||||
components.append(base_component)
|
components.append(base_component)
|
||||||
|
@ -36,7 +36,7 @@ class BackupContents:
|
|||||||
|
|
||||||
def read_tables(self) -> dict:
|
def read_tables(self) -> dict:
|
||||||
if self._tables is None:
|
if self._tables is None:
|
||||||
with open(self.tables, "r") as f:
|
with open(self.tables) as f:
|
||||||
self._tables = json.load(f)
|
self._tables = json.load(f)
|
||||||
|
|
||||||
return self._tables
|
return self._tables
|
||||||
|
@ -10,7 +10,7 @@ from mealie.services.recipe.recipe_data_service import RecipeDataService
|
|||||||
class MigrationReaders:
|
class MigrationReaders:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def json(json_file: Path) -> dict:
|
def json(json_file: Path) -> dict:
|
||||||
with open(json_file, "r") as f:
|
with open(json_file) as f:
|
||||||
return json.loads(f.read())
|
return json.loads(f.read())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -24,7 +24,7 @@ class MigrationReaders:
|
|||||||
Returns:
|
Returns:
|
||||||
dict: representing the yaml file as a dictionary
|
dict: representing the yaml file as a dictionary
|
||||||
"""
|
"""
|
||||||
with open(yaml_file, "r") as f:
|
with open(yaml_file) as f:
|
||||||
contents = f.read().split("---")
|
contents = f.read().split("---")
|
||||||
recipe_data = {}
|
recipe_data = {}
|
||||||
for document in contents:
|
for document in contents:
|
||||||
|
@ -95,7 +95,7 @@ def insideParenthesis(token, tokens):
|
|||||||
else:
|
else:
|
||||||
line = " ".join(tokens)
|
line = " ".join(tokens)
|
||||||
return (
|
return (
|
||||||
re.match(r".*\(.*" + re.escape(token) + ".*\).*", line) is not None # noqa: W605 - invalid dscape sequence
|
re.match(r".*\(.*" + re.escape(token) + r".*\).*", line) is not None # noqa: W605 - invalid dscape sequence
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ def displayIngredient(ingredient):
|
|||||||
# => <span class='qty'>1</span> <span class='name'>cat pie</span>
|
# => <span class='qty'>1</span> <span class='name'>cat pie</span>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return "".join(["<span class='%s'>%s</span>" % (tag, " ".join(tokens)) for tag, tokens in ingredient])
|
return "".join(["<span class='{}'>{}</span>".format(tag, " ".join(tokens)) for tag, tokens in ingredient])
|
||||||
|
|
||||||
|
|
||||||
# HACK: fix this
|
# HACK: fix this
|
||||||
@ -189,7 +189,7 @@ def import_data(lines):
|
|||||||
|
|
||||||
# turn B-NAME/123 back into "name"
|
# turn B-NAME/123 back into "name"
|
||||||
tag, confidence = re.split(r"/", columns[-1], 1)
|
tag, confidence = re.split(r"/", columns[-1], 1)
|
||||||
tag = re.sub("^[BI]\-", "", tag).lower() # noqa: W605 - invalid dscape sequence
|
tag = re.sub(r"^[BI]\-", "", tag).lower() # noqa: W605 - invalid dscape sequence
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# Confidence Getter
|
# Confidence Getter
|
||||||
@ -231,9 +231,7 @@ def import_data(lines):
|
|||||||
data[-1][tag].append(token)
|
data[-1][tag].append(token)
|
||||||
|
|
||||||
# reassemble the output into a list of dicts.
|
# reassemble the output into a list of dicts.
|
||||||
output = [
|
output = [{k: smartJoin(tokens) for k, tokens in ingredient.items()} for ingredient in data if len(ingredient)]
|
||||||
dict([(k, smartJoin(tokens)) for k, tokens in ingredient.items()]) for ingredient in data if len(ingredient)
|
|
||||||
]
|
|
||||||
|
|
||||||
# Preclean Confidence
|
# Preclean Confidence
|
||||||
for i, c in enumerate(confidence_all):
|
for i, c in enumerate(confidence_all):
|
||||||
|
@ -105,7 +105,7 @@ class TemplateService(BaseService):
|
|||||||
if not j2_path.is_file():
|
if not j2_path.is_file():
|
||||||
raise FileNotFoundError(f"Template '{j2_path}' not found.")
|
raise FileNotFoundError(f"Template '{j2_path}' not found.")
|
||||||
|
|
||||||
with open(j2_path, "r") as f:
|
with open(j2_path) as f:
|
||||||
template_text = f.read()
|
template_text = f.read()
|
||||||
|
|
||||||
template = Template(template_text)
|
template = Template(template_text)
|
||||||
|
@ -11,7 +11,7 @@ from tests.utils.fixture_schemas import TestUser
|
|||||||
|
|
||||||
def test_recipe_repo_get_by_categories_basic(database: AllRepositories, unique_user: TestUser):
|
def test_recipe_repo_get_by_categories_basic(database: AllRepositories, unique_user: TestUser):
|
||||||
# Bootstrap the database with categories
|
# Bootstrap the database with categories
|
||||||
slug1, slug2, slug3 = [random_string(10) for _ in range(3)]
|
slug1, slug2, slug3 = (random_string(10) for _ in range(3))
|
||||||
|
|
||||||
categories: list[CategoryOut | CategorySave] = [
|
categories: list[CategoryOut | CategorySave] = [
|
||||||
CategorySave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
CategorySave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
||||||
@ -68,7 +68,7 @@ def test_recipe_repo_get_by_categories_basic(database: AllRepositories, unique_u
|
|||||||
|
|
||||||
|
|
||||||
def test_recipe_repo_get_by_categories_multi(database: AllRepositories, unique_user: TestUser):
|
def test_recipe_repo_get_by_categories_multi(database: AllRepositories, unique_user: TestUser):
|
||||||
slug1, slug2 = [random_string(10) for _ in range(2)]
|
slug1, slug2 = (random_string(10) for _ in range(2))
|
||||||
|
|
||||||
categories = [
|
categories = [
|
||||||
CategorySave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
CategorySave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
||||||
@ -120,7 +120,7 @@ def test_recipe_repo_get_by_categories_multi(database: AllRepositories, unique_u
|
|||||||
|
|
||||||
|
|
||||||
def test_recipe_repo_pagination_by_categories(database: AllRepositories, unique_user: TestUser):
|
def test_recipe_repo_pagination_by_categories(database: AllRepositories, unique_user: TestUser):
|
||||||
slug1, slug2 = [random_string(10) for _ in range(2)]
|
slug1, slug2 = (random_string(10) for _ in range(2))
|
||||||
|
|
||||||
categories = [
|
categories = [
|
||||||
CategorySave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
CategorySave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
||||||
@ -201,7 +201,7 @@ def test_recipe_repo_pagination_by_categories(database: AllRepositories, unique_
|
|||||||
|
|
||||||
|
|
||||||
def test_recipe_repo_pagination_by_tags(database: AllRepositories, unique_user: TestUser):
|
def test_recipe_repo_pagination_by_tags(database: AllRepositories, unique_user: TestUser):
|
||||||
slug1, slug2 = [random_string(10) for _ in range(2)]
|
slug1, slug2 = (random_string(10) for _ in range(2))
|
||||||
|
|
||||||
tags = [
|
tags = [
|
||||||
TagSave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
TagSave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
||||||
@ -280,7 +280,7 @@ def test_recipe_repo_pagination_by_tags(database: AllRepositories, unique_user:
|
|||||||
|
|
||||||
|
|
||||||
def test_recipe_repo_pagination_by_tools(database: AllRepositories, unique_user: TestUser):
|
def test_recipe_repo_pagination_by_tools(database: AllRepositories, unique_user: TestUser):
|
||||||
slug1, slug2 = [random_string(10) for _ in range(2)]
|
slug1, slug2 = (random_string(10) for _ in range(2))
|
||||||
|
|
||||||
tools = [
|
tools = [
|
||||||
RecipeToolSave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
RecipeToolSave(group_id=unique_user.group_id, name=slug1, slug=slug1),
|
||||||
|
@ -11,7 +11,7 @@ ocr_service = OcrService()
|
|||||||
def test_image_to_string():
|
def test_image_to_string():
|
||||||
with open(Path("tests/data/images/test-ocr.png"), "rb") as image:
|
with open(Path("tests/data/images/test-ocr.png"), "rb") as image:
|
||||||
result = ocr_service.image_to_string(image)
|
result = ocr_service.image_to_string(image)
|
||||||
with open(Path("tests/data/text/test-ocr.txt"), "r", encoding="utf-8") as expected_result:
|
with open(Path("tests/data/text/test-ocr.txt"), encoding="utf-8") as expected_result:
|
||||||
assert result == expected_result.read()
|
assert result == expected_result.read()
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ def test_image_to_string():
|
|||||||
def test_image_to_tsv():
|
def test_image_to_tsv():
|
||||||
with open(Path("tests/data/images/test-ocr.png"), "rb") as image:
|
with open(Path("tests/data/images/test-ocr.png"), "rb") as image:
|
||||||
result = ocr_service.image_to_tsv(image.read())
|
result = ocr_service.image_to_tsv(image.read())
|
||||||
with open(Path("tests/data/text/test-ocr.tsv"), "r", encoding="utf-8") as expected_result:
|
with open(Path("tests/data/text/test-ocr.tsv"), encoding="utf-8") as expected_result:
|
||||||
assert result == expected_result.read()
|
assert result == expected_result.read()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user