1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-04 21:15:22 +02:00

feat(backend): 🚧 stub out new exporter service (WIP) (#715)

* chore(backend): 🎨 add isort path to vscode settings

* style(frontend): 💄 remove fab and add general create button

* feat(backend): 🚧 stub out new exporter service

* comment out stub tests

Co-authored-by: Hayden <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-10-02 11:37:04 -08:00 committed by GitHub
parent 476aefeeb0
commit 4bdba9f3af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 714 additions and 50 deletions

View file

@ -0,0 +1,15 @@
# from fastapi.testclient import TestClient
# from tests.utils.fixture_schemas import TestUser
# class Routes:
# base = "/api/groups/manage/data" # Not sure if this is a good url?!?!?
# def test_recipe_export(api_client: TestClient, unique_user: TestUser) -> None:
# assert False
# def test_recipe_import(api_client: TestClient, unique_user: TestUser) -> None:
# assert False

View file

@ -0,0 +1,52 @@
from fastapi.testclient import TestClient
from tests.utils.factories import random_string
from tests.utils.fixture_schemas import TestUser
class Routes:
base = "/api/recipes"
exports = base + "/exports"
@staticmethod
def item(slug: str, file_name: str) -> str:
return f"/api/recipes/{slug}/exports?template_name={file_name}"
def test_get_available_exports(api_client: TestClient, unique_user: TestUser) -> None:
# Get Templates
response = api_client.get(Routes.exports, headers=unique_user.token)
# Assert Templates are Available
assert response.status_code == 200
as_json = response.json()
assert "recipes.md" in as_json["jinja2"]
assert "raw" in as_json["json"]
def test_render_jinja_template(api_client: TestClient, unique_user: TestUser) -> None:
# Create Recipe
recipe_name = random_string()
response = api_client.post(Routes.base, json={"name": recipe_name}, headers=unique_user.token)
assert response.status_code == 201
slug = response.json()
# Render Template
response = api_client.get(Routes.item(slug, "recipes.md"), headers=unique_user.token)
assert response.status_code == 200
# Assert Template is Rendered Correctly
# TODO: More robust test
assert f"# {recipe_name}" in response.text
# TODO: Allow users to upload templates to their own directory
# def test_upload_template(api_client: TestClient, unique_user: TestUser) -> None:
# assert False
# # TODO: Allow users to upload templates to their own directory
# def test_delete_template(api_client: TestClient, unique_user: TestUser) -> None:
# assert False

View file

@ -16,9 +16,7 @@ USER_ID = 2
def test_ownership_on_new_with_admin(api_client: TestClient, admin_token):
recipe_name = random_string()
response = api_client.post(Routes.base, json={"name": recipe_name}, headers=admin_token)
assert response.status_code == 201
recipe = api_client.get(Routes.base + f"/{recipe_name}", headers=admin_token).json()

View file

@ -0,0 +1,8 @@
from mealie.services.recipe.template_service import TemplateService, TemplateType
def test_recipe_export_types() -> None:
ts = TemplateService()
assert ts.template_type("recipes.md") == TemplateType.jinja2.value
assert ts.template_type("raw") == TemplateType.json.value
assert ts.template_type("zip") == TemplateType.zip.value