37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""Workflow uniqueness is independent of the selected task skills."""
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
from calliope.routers.agent import MessageCreate
|
|
|
|
|
|
def workflow(n=1):
|
|
return {"type": "workflow", "id": n, "name": f"workflow-{n}", "kind": "image"}
|
|
|
|
|
|
def skill(n=1):
|
|
return {"type": "skill", "name": f"skill-{n}"}
|
|
|
|
|
|
def test_workflow_and_skills_can_be_sent_together():
|
|
message = MessageCreate(content="Create an image", mentions=[workflow(), *[skill(i) for i in range(4)]])
|
|
assert len(message.mentions) == 5
|
|
assert message.mentions[0].id == 1
|
|
|
|
|
|
def test_legacy_single_workflow_is_accepted():
|
|
assert MessageCreate(mentions=[workflow()]).mentions[0].type == "workflow"
|
|
|
|
|
|
def test_skills_without_workflow_are_accepted():
|
|
assert len(MessageCreate(mentions=[skill(i) for i in range(4)]).mentions) == 4
|
|
|
|
|
|
def test_second_workflow_is_still_rejected():
|
|
with pytest.raises(ValidationError, match="Only one @workflow"):
|
|
MessageCreate(mentions=[workflow(), skill(), workflow(2)])
|
|
|
|
|
|
def test_fifth_skill_is_rejected():
|
|
with pytest.raises(ValidationError, match="At most four skill"):
|
|
MessageCreate(mentions=[skill(i) for i in range(5)])
|