v0.2.0 Updates (#130)

* migration redesign init

* new color picker

* changelog

* added UI language selection

* fix layout issue on recipe editor

* remove git as dependency

* added UI editor for original URL

* CI/CD Tests

* test: fixed migration routes

* test todos

* bug/added docker volume

* chowdow test data

* partial image recipe image testing

* added card section card

* settings form

* homepage cetegory ui

* frontend category placeholder

* fixed broken scheduler

* remove old files

* removed temp test

Co-authored-by: Hayden <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-01-29 19:31:24 -08:00
committed by GitHub
parent ce48ae61c7
commit 874bea7fa4
42 changed files with 763 additions and 746 deletions

View File

@@ -3,25 +3,57 @@ import shutil
import pytest
from app_config import MIGRATION_DIR
from tests.test_config import TEST_NEXTCLOUD_DIR
#! Broken
# def test_import_chowdown_recipes(api_client):
# response = api_client.post(
# "/api/migration/chowdown/repo/",
# json={"url": "https://github.com/hay-kot/chowdown"},
# )
# assert response.status_code == 200
# test_slug = "banana-bread"
# response = api_client.get(f"/api/recipe/{test_slug}/")
# assert response.status_code == 200
# recipe = json.loads(response.content)
# assert recipe["slug"] == test_slug
from tests.test_config import TEST_CHOWDOWN_DIR, TEST_NEXTCLOUD_DIR
### Chowdown
@pytest.fixture(scope="session")
def chowdown_zip():
zip = TEST_CHOWDOWN_DIR.joinpath("test_chowdown-gh-pages.zip")
zip_copy = TEST_CHOWDOWN_DIR.joinpath("chowdown-gh-pages.zip")
shutil.copy(zip, zip_copy)
yield zip_copy
zip_copy.unlink()
def test_upload_chowdown_zip(api_client, chowdown_zip):
response = api_client.post(
"/api/migrations/chowdown/upload/", files={"archive": chowdown_zip.open("rb")}
)
assert response.status_code == 200
assert MIGRATION_DIR.joinpath("chowdown", chowdown_zip.name).is_file()
def test_import_chowdown_directory(api_client, chowdown_zip):
selection = chowdown_zip.name
response = api_client.post(f"/api/migrations/chowdown/{selection}/import/")
assert response.status_code == 200
report = json.loads(response.content)
assert report["failed"] == []
expected_slug = "roasted-okra"
response = api_client.get(f"/api/recipe/{expected_slug}/")
assert response.status_code == 200
def test_delete_chowdown_migration_data(api_client, chowdown_zip):
selection = chowdown_zip.name
response = api_client.delete(f"/api/migrations/chowdown/{selection}/delete/")
assert response.status_code == 200
assert not MIGRATION_DIR.joinpath(chowdown_zip.name).is_file()
### Nextcloud
@pytest.fixture(scope="session")
def nextcloud_zip():
zip = TEST_NEXTCLOUD_DIR.joinpath("nextcloud.zip")
@@ -30,7 +62,9 @@ def nextcloud_zip():
shutil.copy(zip, zip_copy)
return zip_copy
yield zip_copy
zip_copy.unlink()
def test_upload_nextcloud_zip(api_client, nextcloud_zip):
@@ -58,7 +92,7 @@ def test_import_nextcloud_directory(api_client, nextcloud_zip):
assert response.status_code == 200
def test_delete_migration_data(api_client, nextcloud_zip):
def test_delete__nextcloud_migration_data(api_client, nextcloud_zip):
selection = nextcloud_zip.name
response = api_client.delete(f"/api/migrations/nextcloud/{selection}/delete/")

View File

@@ -2,9 +2,12 @@ import json
import pytest
from slugify import slugify
from tests.test_routes.utils.routes_data import (RecipeTestData,
raw_recipe_dict,
recipe_test_data)
from tests.test_routes.utils.routes_data import (
RecipeTestData,
raw_recipe,
raw_recipe_no_image,
recipe_test_data,
)
@pytest.mark.parametrize("recipe_data", recipe_test_data)
@@ -15,12 +18,31 @@ def test_create_by_url(api_client, recipe_data: RecipeTestData):
def test_create_by_json(api_client):
response = api_client.post("/api/recipe/create/", json=raw_recipe_dict)
response = api_client.post("/api/recipe/create/", json=raw_recipe)
assert response.status_code == 200
assert json.loads(response.text) == "banana-bread"
def test_create_no_image(api_client):
response = api_client.post("/api/recipe/create/", json=raw_recipe_no_image)
assert response.status_code == 200
assert json.loads(response.text) == "banana-bread-no-image"
# def test_upload_image(api_client, test_image):
# data = {"image": test_image.open("rb").read(), "extension": "jpg"}
# response = api_client.post(
# "/api/recipe/banana-bread-no-image/update/image/", files=data
# )
# assert response.status_code == 200
# response = api_client.get("/api/recipe/banana-bread-no-image/update/image/")
def test_read_all_post(api_client):
response = api_client.post(
"/api/all-recipes/", json={"properties": ["slug", "description", "rating"]}

View File

@@ -16,7 +16,7 @@ recipe_test_data = [
]
raw_recipe_dict = {
raw_recipe = {
"name": "Banana Bread",
"description": "From Angie's mom",
"image": "banana-bread.jpg",
@@ -62,3 +62,50 @@ raw_recipe_dict = {
"orgURL": None,
"extras": {},
}
raw_recipe_no_image = {
"name": "Banana Bread No Image",
"description": "From Angie's mom",
"image": "",
"recipeYield": "",
"recipeIngredient": [
"4 bananas",
"1/2 cup butter",
"1/2 cup sugar",
"2 eggs",
"2 cups flour",
"1/2 tsp baking soda",
"1 tsp baking powder",
"pinch salt",
"1/4 cup nuts (we like pecans)",
],
"recipeInstructions": [
{
"@type": "Beat the eggs, then cream with the butter and sugar",
"text": "Beat the eggs, then cream with the butter and sugar",
},
{
"@type": "Mix in bananas, then flour, baking soda/powder, salt, and nuts",
"text": "Mix in bananas, then flour, baking soda/powder, salt, and nuts",
},
{
"@type": "Add to greased and floured pan",
"text": "Add to greased and floured pan",
},
{
"@type": "Bake until brown/cracked, toothpick comes out clean",
"text": "Bake until brown/cracked, toothpick comes out clean",
},
],
"totalTime": "None",
"prepTime": None,
"performTime": None,
"slug": "",
"categories": [],
"tags": ["breakfast", " baking"],
"dateAdded": "2021-01-12",
"notes": [],
"rating": 0,
"orgURL": None,
"extras": {},
}