refactor: finish declutter - test_flow removal, NOT NULL schema, parametrized tests, smoke harness, docs
This commit is contained in:
parent
696db34c90
commit
92bb3bacba
23 changed files with 552 additions and 1261 deletions
|
|
@ -1,5 +1,7 @@
|
|||
"""Model-level tests: defaults, constraints, JSON roundtrip, linkage."""
|
||||
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlmodel import select
|
||||
|
|
@ -86,3 +88,48 @@ def test_run_and_task_linkage_with_tenant_default(session):
|
|||
tasks = session.exec(select(ApprovalTask).where(ApprovalTask.run_id == run.id)).all()
|
||||
assert len(tasks) == 1
|
||||
assert tasks[0].payload == {}
|
||||
|
||||
|
||||
def test_create_version_populates_input_schema(session):
|
||||
from app.flows import store
|
||||
from app.flows.schemas import FlowVersionCreate
|
||||
|
||||
d = FlowDefinition(name="cached")
|
||||
session.add(d)
|
||||
session.commit()
|
||||
doc = {
|
||||
"name": "cached",
|
||||
"data": {
|
||||
"nodes": [
|
||||
{
|
||||
"id": "n1",
|
||||
"data": {
|
||||
"type": "ChatInput",
|
||||
"node": {"display_name": "Chat", "template": {}},
|
||||
},
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
},
|
||||
}
|
||||
version = store.create_version(session, d.id, FlowVersionCreate(langflow_json=doc))
|
||||
assert version.input_schema["fallback"] == "textarea"
|
||||
|
||||
|
||||
def test_input_schema_null_rejected(session):
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
d = FlowDefinition(name="nonnull")
|
||||
session.add(d)
|
||||
session.commit()
|
||||
with pytest.raises(IntegrityError):
|
||||
session.execute(
|
||||
text(
|
||||
"INSERT INTO flow_versions (id, flow_id, version_no, langflow_json,"
|
||||
" author, input_schema) VALUES (:id, :flow_id, 1, :doc, :author, NULL)"
|
||||
),
|
||||
{"id": str(uuid.uuid4()), "flow_id": str(d.id), "doc": "{}", "author": "t"},
|
||||
)
|
||||
session.commit()
|
||||
session.rollback()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue