fix(recipe): task di default per il disegno e' task_type=drawing (#36 punto 5)
update_current_version creava il task di default (nessun task ancora sulla versione) senza task_type, quindi finiva "note" invece di "drawing" come fa create_new_version alla riga ~293. Aggiunta la riga mancante. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -425,6 +425,7 @@ async def update_current_version(
|
|||||||
default_task = RecipeTask(
|
default_task = RecipeTask(
|
||||||
version_id=current.id,
|
version_id=current.id,
|
||||||
order_index=0,
|
order_index=0,
|
||||||
|
task_type="drawing",
|
||||||
title="Technical Drawing",
|
title="Technical Drawing",
|
||||||
file_path=data.file_path,
|
file_path=data.file_path,
|
||||||
file_type=data.file_type or (
|
file_type=data.file_type or (
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
"""Unit test for recipe_service.update_current_version (gitea#36 point 5).
|
||||||
|
|
||||||
|
The default task created to hold a drawing when a version has no tasks yet
|
||||||
|
must be task_type="drawing" (as create_new_version already does at line
|
||||||
|
~293), not the "note" default — otherwise the operator screen treats a
|
||||||
|
version with only a drawing as an empty note.
|
||||||
|
"""
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
|
from src.backend.models.api.recipe import RecipeUpdate
|
||||||
|
from src.backend.models.orm.recipe import Recipe, RecipeVersion
|
||||||
|
from src.backend.models.orm.task import RecipeTask
|
||||||
|
from src.backend.services import recipe_service
|
||||||
|
|
||||||
|
|
||||||
|
async def test_default_task_from_update_current_version_is_drawing_type(
|
||||||
|
db_session: AsyncSession, admin_user,
|
||||||
|
):
|
||||||
|
recipe = Recipe(
|
||||||
|
code="DRAW-425", name="Drawing only", created_by=admin_user.id,
|
||||||
|
)
|
||||||
|
db_session.add(recipe)
|
||||||
|
await db_session.flush()
|
||||||
|
|
||||||
|
version = RecipeVersion(
|
||||||
|
recipe_id=recipe.id, version_number=1, is_current=True,
|
||||||
|
created_by=admin_user.id,
|
||||||
|
)
|
||||||
|
db_session.add(version)
|
||||||
|
await db_session.flush()
|
||||||
|
# No RecipeTask yet: update_current_version must create the default one.
|
||||||
|
|
||||||
|
await recipe_service.update_current_version(
|
||||||
|
db_session, recipe.id, RecipeUpdate(file_path="1/1/drawing.png"),
|
||||||
|
)
|
||||||
|
await db_session.commit()
|
||||||
|
|
||||||
|
result = await db_session.execute(
|
||||||
|
RecipeTask.__table__.select().where(RecipeTask.version_id == version.id)
|
||||||
|
)
|
||||||
|
task = result.mappings().one()
|
||||||
|
assert task["task_type"] == "drawing"
|
||||||
Reference in New Issue
Block a user