From 842989647e3141df40dea9c84fb50ed897a8ed35 Mon Sep 17 00:00:00 2001 From: Richard Mitic Date: Wed, 6 Jan 2021 18:01:46 +0100 Subject: [PATCH 1/5] Remove test directory in production docker image --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index e98a95f734c2..5ca8fc352895 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ RUN pip install -r requirements.txt COPY ./mealie /app COPY ./mealie/data/templates/recipes.md /app/data/templates/ COPY --from=build-stage /app/dist /app/dist +RUN rm -rf /app/test ENV ENV prod From b6bd44c8f11917a025ce1c00f6203153335d0b52 Mon Sep 17 00:00:00 2001 From: Hayden Date: Wed, 6 Jan 2021 08:32:36 -0900 Subject: [PATCH 2/5] bind mount on docker-compose --- docs/docs/getting-started/install.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/docs/getting-started/install.md b/docs/docs/getting-started/install.md index 4a7404f9b6d0..4572e68c7dc4 100644 --- a/docs/docs/getting-started/install.md +++ b/docs/docs/getting-started/install.md @@ -38,12 +38,13 @@ services: db_port: 27017 # The Default port for Mongo DB TZ: America/Anchorage volumes: - - ./data/img:/app/data/img - - ./data/backups:/app/data/backups + - ./mealie/data/:/app/data/ mongo: image: mongo restart: always + volumes: + - ./mongo:/data/db environment: MONGO_INITDB_ROOT_USERNAME: root # Change! MONGO_INITDB_ROOT_PASSWORD: example # Change! @@ -56,6 +57,7 @@ services: environment: ME_CONFIG_MONGODB_ADMINUSERNAME: root ME_CONFIG_MONGODB_ADMINPASSWORD: example + ``` ## Ansible Tasks Template From 8ab1bdeb4aa2366155054edceee76d54bb452feb Mon Sep 17 00:00:00 2001 From: Richard Mitic Date: Wed, 6 Jan 2021 18:37:35 +0100 Subject: [PATCH 3/5] Fix bug in instruction normalization --- mealie/services/scrape_services.py | 2 +- mealie/test/test_scraper.py | 71 ++++++++++++------------------ 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/mealie/services/scrape_services.py b/mealie/services/scrape_services.py index a0a9e7330589..7f5a180be7a4 100644 --- a/mealie/services/scrape_services.py +++ b/mealie/services/scrape_services.py @@ -28,7 +28,7 @@ def normalize_image_url(image) -> str: def normalize_instructions(instructions) -> List[dict]: # One long string split by (possibly multiple) new lines if type(instructions) == str: - return [{"text": line.strip()} for line in filter(None, instructions.split("\n"))] + return [{"text": line.strip()} for line in filter(None, instructions.splitlines())] # Plain strings in a list elif type(instructions) == list and type(instructions[0]) == str: diff --git a/mealie/test/test_scraper.py b/mealie/test/test_scraper.py index fba25f7ba617..af5cbfae9860 100644 --- a/mealie/test/test_scraper.py +++ b/mealie/test/test_scraper.py @@ -7,48 +7,33 @@ from services.scrape_services import normalize_data, normalize_instructions CWD = Path(__file__).parent RAW_RECIPE_DIR = CWD.joinpath("data", "recipes-raw") -def pytest_generate_tests(metafunc): - # called once per each test function - funcarglist = metafunc.cls.params[metafunc.function.__name__] - argnames = sorted(funcarglist[0]) - metafunc.parametrize( - argnames, [[funcargs[name] for name in argnames] for funcargs in funcarglist] - ) + +@pytest.mark.parametrize("json_file,num_steps", [ + ("best-homemade-salsa-recipe.json", 2), + ("blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2.json", 3), + ("bon_appetit.json", 8), + ("chunky-apple-cake.json", 4), + ("dairy-free-impossible-pumpkin-pie.json", 7), + ("how-to-make-instant-pot-spaghetti.json", 8), + ("instant-pot-chicken-and-potatoes.json", 4), + ("instant-pot-kerala-vegetable-stew.json", 13), + ("jalapeno-popper-dip.json", 4), + ("microwave_sweet_potatoes_04783.json", 4), + ("moroccan-skirt-steak-with-roasted-pepper-couscous.json", 4), + ("Pizza-Knoblauch-Champignon-Paprika-vegan.html.json", 3), +]) +def test_normalize_data(json_file, num_steps): + recipe_data = normalize_data(json.load(open(RAW_RECIPE_DIR.joinpath(json_file)))) + assert len(recipe_data["recipeInstructions"]) == num_steps -def raw_recipe_info(file_name: str, num_steps: int) -> dict: - return {"json_file": RAW_RECIPE_DIR.joinpath(file_name), "num_steps": num_steps} - - -class TestScraper: - # a map specifying multiple argument sets for a test method - params = { - "test_normalize_instructions": [ - dict(instructions="A\n\nB\n\nC\n\n"), - dict(instructions=["A","B","C"]), - dict(instructions=[{"@type": "HowToStep", "text": "A"}, - {"@type": "HowToStep", "text": "B"}, - {"@type": "HowToStep", "text": "C"}]), - ], - "test_normalize_data": [ - raw_recipe_info("best-homemade-salsa-recipe.json", 2), - raw_recipe_info("blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2.json", 3), - raw_recipe_info("bon_appetit.json", 8), - raw_recipe_info("chunky-apple-cake.json", 4), - raw_recipe_info("dairy-free-impossible-pumpkin-pie.json", 7), - raw_recipe_info("how-to-make-instant-pot-spaghetti.json", 8), - raw_recipe_info("instant-pot-chicken-and-potatoes.json", 4), - raw_recipe_info("instant-pot-kerala-vegetable-stew.json", 13), - raw_recipe_info("jalapeno-popper-dip.json", 4), - raw_recipe_info("microwave_sweet_potatoes_04783.json", 4), - raw_recipe_info("moroccan-skirt-steak-with-roasted-pepper-couscous.json", 4), - raw_recipe_info("Pizza-Knoblauch-Champignon-Paprika-vegan.html.json", 5), - ] - } - - def test_normalize_data(self, json_file, num_steps): - recipe_data = normalize_data(json.load(open(json_file))) - assert len(recipe_data["recipeInstructions"]) == num_steps - - def test_normalize_instructions(self, instructions): - assert normalize_instructions(instructions) == [{"text": "A"}, {"text": "B"}, {"text": "C"}] +@pytest.mark.parametrize("instructions", [ + "A\n\nB\n\nC\n\n", + "A\nB\nC\n", + "A\r\n\r\nB\r\n\r\nC\r\n\r\n", + "A\r\nB\r\nC\r\n", + ["A","B","C"], + [{"@type": "HowToStep", "text": x} for x in ["A","B","C"]] +]) +def test_normalize_instructions(instructions): + assert normalize_instructions(instructions) == [{"text": "A"}, {"text": "B"}, {"text": "C"}] From 9612a6b24d8bfdad622ff22b5e3ce9f2c73bad2d Mon Sep 17 00:00:00 2001 From: Hayden Date: Wed, 6 Jan 2021 08:37:52 -0900 Subject: [PATCH 4/5] spacing issue --- docs/docs/getting-started/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/getting-started/install.md b/docs/docs/getting-started/install.md index 4572e68c7dc4..7742622c1d9e 100644 --- a/docs/docs/getting-started/install.md +++ b/docs/docs/getting-started/install.md @@ -44,7 +44,7 @@ services: image: mongo restart: always volumes: - - ./mongo:/data/db + - ./mongo:/data/db environment: MONGO_INITDB_ROOT_USERNAME: root # Change! MONGO_INITDB_ROOT_PASSWORD: example # Change! From 0fe26128ff3ad0a2ef1872a4454536366bede99f Mon Sep 17 00:00:00 2001 From: Hayden Date: Wed, 6 Jan 2021 08:39:48 -0900 Subject: [PATCH 5/5] close button + resest error --- frontend/src/components/AddRecipe.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/AddRecipe.vue b/frontend/src/components/AddRecipe.vue index 4bd0718473ca..b44838374699 100644 --- a/frontend/src/components/AddRecipe.vue +++ b/frontend/src/components/AddRecipe.vue @@ -19,7 +19,8 @@ - Submit + Close + Submit @@ -73,10 +74,11 @@ export default { }, reset() { - (this.fab = false), - (this.addRecipe = false), - (this.recipeURL = ""), - (this.processing = false); + this.fab = false; + this.error = false; + this.addRecipe = false; + this.recipeURL = ""; + this.processing = false; }, }, };