diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Air Fryer Shrimp/full.jpg b/mealie/tests/data/migrations/nextcloud/Air Fryer Shrimp/full.jpg similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Air Fryer Shrimp/full.jpg rename to mealie/tests/data/migrations/nextcloud/Air Fryer Shrimp/full.jpg diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Air Fryer Shrimp/recipe.json b/mealie/tests/data/migrations/nextcloud/Air Fryer Shrimp/recipe.json similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Air Fryer Shrimp/recipe.json rename to mealie/tests/data/migrations/nextcloud/Air Fryer Shrimp/recipe.json diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Air Fryer Shrimp/thumb.jpg b/mealie/tests/data/migrations/nextcloud/Air Fryer Shrimp/thumb.jpg similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Air Fryer Shrimp/thumb.jpg rename to mealie/tests/data/migrations/nextcloud/Air Fryer Shrimp/thumb.jpg diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Chicken Parmigiana/full.jpg b/mealie/tests/data/migrations/nextcloud/Chicken Parmigiana/full.jpg similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Chicken Parmigiana/full.jpg rename to mealie/tests/data/migrations/nextcloud/Chicken Parmigiana/full.jpg diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Chicken Parmigiana/recipe.json b/mealie/tests/data/migrations/nextcloud/Chicken Parmigiana/recipe.json similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Chicken Parmigiana/recipe.json rename to mealie/tests/data/migrations/nextcloud/Chicken Parmigiana/recipe.json diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Chicken Parmigiana/thumb.jpg b/mealie/tests/data/migrations/nextcloud/Chicken Parmigiana/thumb.jpg similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Chicken Parmigiana/thumb.jpg rename to mealie/tests/data/migrations/nextcloud/Chicken Parmigiana/thumb.jpg diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Skillet Shepherd's Pie/recipe.json b/mealie/tests/data/migrations/nextcloud/Skillet Shepherd's Pie/recipe.json similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/Skillet Shepherd's Pie/recipe.json rename to mealie/tests/data/migrations/nextcloud/Skillet Shepherd's Pie/recipe.json diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/new_nextcloud.zip b/mealie/tests/data/migrations/nextcloud/new_nextcloud.zip similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/new_nextcloud.zip rename to mealie/tests/data/migrations/nextcloud/new_nextcloud.zip diff --git a/mealie/tests/test_services/test_migrations/data/nextcloud_recipes/nextcloud.zip b/mealie/tests/data/migrations/nextcloud/nextcloud.zip similarity index 100% rename from mealie/tests/test_services/test_migrations/data/nextcloud_recipes/nextcloud.zip rename to mealie/tests/data/migrations/nextcloud/nextcloud.zip diff --git a/mealie/tests/test_services/test_scraper/data/html-raw/carottes-rapps-with-rice-and-sunflower-seeds.html b/mealie/tests/data/scraper/html-raw/carottes-rapps-with-rice-and-sunflower-seeds.html similarity index 100% rename from mealie/tests/test_services/test_scraper/data/html-raw/carottes-rapps-with-rice-and-sunflower-seeds.html rename to mealie/tests/data/scraper/html-raw/carottes-rapps-with-rice-and-sunflower-seeds.html diff --git a/mealie/tests/test_services/test_scraper/data/html-raw/healthy_pasta_bake_60759.html b/mealie/tests/data/scraper/html-raw/healthy_pasta_bake_60759.html similarity index 100% rename from mealie/tests/test_services/test_scraper/data/html-raw/healthy_pasta_bake_60759.html rename to mealie/tests/data/scraper/html-raw/healthy_pasta_bake_60759.html diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/Pizza-Knoblauch-Champignon-Paprika-vegan.html.json b/mealie/tests/data/scraper/recipes-raw/Pizza-Knoblauch-Champignon-Paprika-vegan.html.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/Pizza-Knoblauch-Champignon-Paprika-vegan.html.json rename to mealie/tests/data/scraper/recipes-raw/Pizza-Knoblauch-Champignon-Paprika-vegan.html.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/best-homemade-salsa-recipe.json b/mealie/tests/data/scraper/recipes-raw/best-homemade-salsa-recipe.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/best-homemade-salsa-recipe.json rename to mealie/tests/data/scraper/recipes-raw/best-homemade-salsa-recipe.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2.json b/mealie/tests/data/scraper/recipes-raw/blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2.json rename to mealie/tests/data/scraper/recipes-raw/blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/bon_appetit.json b/mealie/tests/data/scraper/recipes-raw/bon_appetit.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/bon_appetit.json rename to mealie/tests/data/scraper/recipes-raw/bon_appetit.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/chunky-apple-cake.json b/mealie/tests/data/scraper/recipes-raw/chunky-apple-cake.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/chunky-apple-cake.json rename to mealie/tests/data/scraper/recipes-raw/chunky-apple-cake.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/dairy-free-impossible-pumpkin-pie.json b/mealie/tests/data/scraper/recipes-raw/dairy-free-impossible-pumpkin-pie.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/dairy-free-impossible-pumpkin-pie.json rename to mealie/tests/data/scraper/recipes-raw/dairy-free-impossible-pumpkin-pie.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/how-to-make-instant-pot-spaghetti.json b/mealie/tests/data/scraper/recipes-raw/how-to-make-instant-pot-spaghetti.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/how-to-make-instant-pot-spaghetti.json rename to mealie/tests/data/scraper/recipes-raw/how-to-make-instant-pot-spaghetti.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/instant-pot-chicken-and-potatoes.json b/mealie/tests/data/scraper/recipes-raw/instant-pot-chicken-and-potatoes.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/instant-pot-chicken-and-potatoes.json rename to mealie/tests/data/scraper/recipes-raw/instant-pot-chicken-and-potatoes.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/instant-pot-kerala-vegetable-stew.json b/mealie/tests/data/scraper/recipes-raw/instant-pot-kerala-vegetable-stew.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/instant-pot-kerala-vegetable-stew.json rename to mealie/tests/data/scraper/recipes-raw/instant-pot-kerala-vegetable-stew.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/jalapeno-popper-dip.json b/mealie/tests/data/scraper/recipes-raw/jalapeno-popper-dip.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/jalapeno-popper-dip.json rename to mealie/tests/data/scraper/recipes-raw/jalapeno-popper-dip.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/microwave_sweet_potatoes_04783.json b/mealie/tests/data/scraper/recipes-raw/microwave_sweet_potatoes_04783.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/microwave_sweet_potatoes_04783.json rename to mealie/tests/data/scraper/recipes-raw/microwave_sweet_potatoes_04783.json diff --git a/mealie/tests/test_services/test_scraper/data/recipes-raw/moroccan-skirt-steak-with-roasted-pepper-couscous.json b/mealie/tests/data/scraper/recipes-raw/moroccan-skirt-steak-with-roasted-pepper-couscous.json similarity index 100% rename from mealie/tests/test_services/test_scraper/data/recipes-raw/moroccan-skirt-steak-with-roasted-pepper-couscous.json rename to mealie/tests/data/scraper/recipes-raw/moroccan-skirt-steak-with-roasted-pepper-couscous.json diff --git a/mealie/tests/test_config.py b/mealie/tests/test_config.py new file mode 100644 index 000000000..bbbc19ef7 --- /dev/null +++ b/mealie/tests/test_config.py @@ -0,0 +1,20 @@ +from pathlib import Path + +CWD = Path(__file__).parent + + +TEST_DIR = CWD +TEST_DATA = CWD.joinpath("data") + +# Scraper +TEST_RAW_HTML = TEST_DATA.joinpath("scraper", "html-raw") +TEST_RAW_RECIPES = TEST_DATA.joinpath("scraper", "recipes-raw") + +# Migrations +TEST_CHOWDOWN_DIR = TEST_DATA.joinpath("migrations", "chowdown") +TEST_NEXTCLOUD_DIR = TEST_DATA.joinpath("migrations", "nextcloud") + +# Routes + +if __name__ == "__main__": + pass diff --git a/mealie/tests/test_routes/test_migration_routes.py b/mealie/tests/test_routes/test_migration_routes.py index a74e5fbbc..e7f4269b9 100644 --- a/mealie/tests/test_routes/test_migration_routes.py +++ b/mealie/tests/test_routes/test_migration_routes.py @@ -1,13 +1,9 @@ import json import shutil -from pathlib import Path - -from app_config import BASE_DIR, MIGRATION_DIR -from tests.test_services.test_migrations.test_nextcloud import NEXTCLOUD_DIR - -TEST_DIR = BASE_DIR.joinpath("tests") import pytest +from app_config import MIGRATION_DIR +from tests.test_config import TEST_NEXTCLOUD_DIR #! Broken # def test_import_chowdown_recipes(api_client): @@ -28,13 +24,9 @@ import pytest @pytest.fixture(scope="session") def nextcloud_zip(): - zip = TEST_DIR.joinpath( - "test_services/test_migrations/data/nextcloud_recipes/nextcloud.zip" - ) + zip = TEST_NEXTCLOUD_DIR.joinpath("nextcloud.zip") - zip_copy = TEST_DIR.joinpath( - "test_services/test_migrations/data/nextcloud_recipes/new_nextcloud.zip" - ) + zip_copy = TEST_NEXTCLOUD_DIR.joinpath("new_nextcloud.zip") shutil.copy(zip, zip_copy) diff --git a/mealie/tests/test_services/test_migrations/test_nextcloud.py b/mealie/tests/test_services/test_migrations/test_nextcloud.py index ec7ef2eea..96bebd0e1 100644 --- a/mealie/tests/test_services/test_migrations/test_nextcloud.py +++ b/mealie/tests/test_services/test_migrations/test_nextcloud.py @@ -1,17 +1,15 @@ from pathlib import Path -from app_config import TEMP_DIR + import pytest +from app_config import TEMP_DIR from services.image_services import IMG_DIR -from services.migrations.nextcloud import ( - cleanup, - import_recipes, - prep, - process_selection, -) +from services.migrations.nextcloud import (cleanup, import_recipes, prep, + process_selection) from services.recipe_services import Recipe +from tests.test_config import TEST_NEXTCLOUD_DIR CWD = Path(__file__).parent -NEXTCLOUD_DIR = CWD.joinpath("data", "nextcloud_recipes") +TEST_NEXTCLOUD_DIR TEMP_NEXTCLOUD = TEMP_DIR.joinpath("nextcloud") @@ -21,7 +19,7 @@ TEMP_NEXTCLOUD = TEMP_DIR.joinpath("nextcloud") ) def test_zip_extraction(file_name: str, final_path: Path): prep() - zip = NEXTCLOUD_DIR.joinpath(file_name) + zip = TEST_NEXTCLOUD_DIR.joinpath(file_name) dir = process_selection(zip) assert dir == final_path @@ -32,9 +30,9 @@ def test_zip_extraction(file_name: str, final_path: Path): @pytest.mark.parametrize( "recipe_dir", [ - NEXTCLOUD_DIR.joinpath("Air Fryer Shrimp"), - NEXTCLOUD_DIR.joinpath("Chicken Parmigiana"), - NEXTCLOUD_DIR.joinpath("Skillet Shepherd's Pie"), + TEST_NEXTCLOUD_DIR.joinpath("Air Fryer Shrimp"), + TEST_NEXTCLOUD_DIR.joinpath("Chicken Parmigiana"), + TEST_NEXTCLOUD_DIR.joinpath("Skillet Shepherd's Pie"), ], ) def test_nextcloud_migration(recipe_dir: Path): diff --git a/mealie/tests/test_services/test_scraper/data/nextcloud.zip b/mealie/tests/test_services/test_scraper/data/nextcloud.zip deleted file mode 100644 index 256395897..000000000 Binary files a/mealie/tests/test_services/test_scraper/data/nextcloud.zip and /dev/null differ diff --git a/mealie/tests/test_services/test_scraper/test_scraper.py b/mealie/tests/test_services/test_scraper/test_scraper.py index ab635dc4d..ebf8321c9 100644 --- a/mealie/tests/test_services/test_scraper/test_scraper.py +++ b/mealie/tests/test_services/test_scraper/test_scraper.py @@ -1,6 +1,5 @@ import json import re -from pathlib import Path import pytest from services.scrape_services import ( @@ -8,10 +7,7 @@ from services.scrape_services import ( normalize_data, normalize_instructions, ) - -CWD = Path(__file__).parent -RAW_RECIPE_DIR = CWD.joinpath("data", "recipes-raw") -RAW_HTML_DIR = CWD.joinpath("data", "html-raw") +from tests.test_config import TEST_RAW_HTML, TEST_RAW_RECIPES # https://github.com/django/django/blob/stable/1.3.x/django/core/validators.py#L45 url_validation_regex = re.compile( @@ -46,7 +42,7 @@ url_validation_regex = re.compile( ], ) def test_normalize_data(json_file, num_steps): - recipe_data = normalize_data(json.load(open(RAW_RECIPE_DIR.joinpath(json_file)))) + recipe_data = normalize_data(json.load(open(TEST_RAW_RECIPES.joinpath(json_file)))) assert len(recipe_data["recipeInstructions"]) == num_steps @@ -70,7 +66,7 @@ def test_normalize_instructions(instructions): def test_html_no_recipe_data(): - path = RAW_HTML_DIR.joinpath("carottes-rapps-with-rice-and-sunflower-seeds.html") + path = TEST_RAW_HTML.joinpath("carottes-rapps-with-rice-and-sunflower-seeds.html") url = "https://www.feedtheswimmers.com/blog/2019/6/5/carottes-rapps-with-rice-and-sunflower-seeds" recipe_data = extract_recipe_from_html(open(path).read(), url) @@ -86,7 +82,7 @@ def test_html_no_recipe_data(): def test_html_with_recipe_data(): - path = RAW_HTML_DIR.joinpath("healthy_pasta_bake_60759.html") + path = TEST_RAW_HTML.joinpath("healthy_pasta_bake_60759.html") url = "https://www.bbc.co.uk/food/recipes/healthy_pasta_bake_60759" recipe_data = extract_recipe_from_html(open(path).read(), url) diff --git a/mealie/tests/utils.py b/mealie/tests/utils.py new file mode 100644 index 000000000..e69de29bb