diff --git a/py/routes/recipe_route_registrar.py b/py/routes/recipe_route_registrar.py index b07327b4..6e1db587 100644 --- a/py/routes/recipe_route_registrar.py +++ b/py/routes/recipe_route_registrar.py @@ -33,7 +33,7 @@ ROUTE_DEFINITIONS: tuple[RouteDefinition, ...] = ( RouteDefinition("GET", "/api/lm/recipes/unified-folder-tree", "get_unified_folder_tree"), RouteDefinition("GET", "/api/lm/recipe/{recipe_id}/share", "share_recipe"), RouteDefinition("GET", "/api/lm/recipe/{recipe_id}/share/download", "download_shared_recipe"), - RouteDefinition("GET", "/api/lm/recipes/syntax", "get_recipe_syntax"), + RouteDefinition("GET", "/api/lm/recipe/{recipe_id}/syntax", "get_recipe_syntax"), RouteDefinition("PUT", "/api/lm/recipe/{recipe_id}/update", "update_recipe"), RouteDefinition("POST", "/api/lm/recipe/move", "move_recipe"), RouteDefinition("POST", "/api/lm/recipes/move-bulk", "move_recipes_bulk"), diff --git a/tests/routes/test_recipe_routes.py b/tests/routes/test_recipe_routes.py index f1292d55..7619e330 100644 --- a/tests/routes/test_recipe_routes.py +++ b/tests/routes/test_recipe_routes.py @@ -15,7 +15,7 @@ from py.config import config from py.routes import base_recipe_routes from py.routes.handlers import recipe_handlers from py.routes.recipe_routes import RecipeRoutes -from py.services.recipes import RecipeValidationError +from py.services.recipes import RecipeValidationError, RecipeNotFoundError from py.services.service_registry import ServiceRegistry @@ -588,8 +588,34 @@ async def test_import_remote_recipe_merges_metadata(monkeypatch, tmp_path: Path) metadata = call["metadata"] gen_params = metadata["gen_params"] - # Priority: request (prompt=request, steps=25) > civitai (prompt=civitai, cfg=7.0) > embedded (prompt=embedded, seed=123) - assert gen_params["prompt"] == "from request" - assert gen_params["steps"] == 25 - assert gen_params["cfg"] == 7.0 assert gen_params["seed"] == 123 + + +async def test_get_recipe_syntax(monkeypatch, tmp_path: Path) -> None: + async with recipe_harness(monkeypatch, tmp_path) as harness: + recipe_id = "test-recipe-id" + harness.scanner.recipes[recipe_id] = { + "id": recipe_id, + "title": "Syntax Test", + "loras": [{"name": "lora1", "weight": 0.5}], + } + + # Mock the method that handlers call + async def fake_get_recipe_syntax_tokens(rid): + if rid == recipe_id: + return [""] + raise RecipeNotFoundError(f"Recipe {rid} not found") + + harness.scanner.get_recipe_syntax_tokens = fake_get_recipe_syntax_tokens + + response = await harness.client.get(f"/api/lm/recipe/{recipe_id}/syntax") + payload = await response.json() + + assert response.status == 200 + assert payload["success"] is True + assert payload["syntax"] == "" + + # Test error path + response_404 = await harness.client.get("/api/lm/recipe/non-existent/syntax") + assert response_404.status == 404 +