Improve Test Coverage (#511)

* add recipe scaling notes

* test theme rename

* fix coverage call to use poetry

* remove print

* remove async

* consolidate test case data

* fix mealplan tests

* remove redundant else

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-06-13 13:09:44 -08:00
committed by GitHub
parent c325a49fc2
commit 2dc9c8e843
17 changed files with 249 additions and 230 deletions

View File

@@ -34,7 +34,6 @@ def authenticate_user(session, email: str, password: str) -> UserInDB:
if not user:
return False
print(user)
if not verify_password(password, user.password):
return False
return user

View File

@@ -19,8 +19,7 @@ from mealie.schema.comments import CommentOut
from mealie.schema.event_notifications import EventNotificationIn
from mealie.schema.events import Event as EventSchema
from mealie.schema.meal import MealPlanOut
from mealie.schema.recipe import (Recipe, RecipeIngredientFood,
RecipeIngredientUnit)
from mealie.schema.recipe import Recipe, RecipeIngredientFood, RecipeIngredientUnit
from mealie.schema.settings import CustomPageOut
from mealie.schema.settings import SiteSettings as SiteSettingsSchema
from mealie.schema.shopping_list import ShoppingListOut

View File

@@ -85,7 +85,7 @@ def validate_long_live_token(session: Session, client_token: str, id: int) -> Us
return token.user
async def validate_file_token(token: Optional[str] = None) -> Path:
def validate_file_token(token: Optional[str] = None) -> Path:
credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="could not validate file token",

View File

@@ -38,14 +38,14 @@ def clean(recipe_data: dict, url=None) -> dict:
def clean_string(text: str) -> str:
if text == "" or text is None:
return ""
else:
cleaned_text = html.unescape(text)
cleaned_text = re.sub("<[^<]+?>", "", cleaned_text)
cleaned_text = re.sub(" +", " ", cleaned_text)
cleaned_text = re.sub("</p>", "\n", cleaned_text)
cleaned_text = re.sub(r"\n\s*\n", "\n\n", cleaned_text)
cleaned_text = cleaned_text.replace("\xa0", " ").replace("\t", " ").strip()
return cleaned_text
cleaned_text = html.unescape(text)
cleaned_text = re.sub("<[^<]+?>", "", cleaned_text)
cleaned_text = re.sub(" +", " ", cleaned_text)
cleaned_text = re.sub("</p>", "\n", cleaned_text)
cleaned_text = re.sub(r"\n\s*\n", "\n\n", cleaned_text)
cleaned_text = cleaned_text.replace("\xa0", " ").replace("\t", " ").strip()
return cleaned_text
def category(category: str):
@@ -82,6 +82,10 @@ def instructions(instructions) -> List[dict]:
if not instructions:
return []
# Dictionary (Keys: step number strings, Values: the instructions)
if isinstance(instructions, dict):
instructions = list(instructions.values())
if isinstance(instructions, list) and isinstance(instructions[0], list):
instructions = instructions[0]