|
1 | 1 | from typing import Any |
2 | 2 |
|
3 | 3 | import pytest |
4 | | -from pydantic import TypeAdapter |
| 4 | +from pydantic import TypeAdapter, ValidationError |
5 | 5 |
|
6 | 6 | from uipath.agent.models.agent import ( |
7 | 7 | AgentA2aResourceConfig, |
|
43 | 43 | AgentUnknownToolResourceConfig, |
44 | 44 | AgentWordOperator, |
45 | 45 | AgentWordRule, |
| 46 | + ArgumentEmailRecipient, |
| 47 | + ArgumentGroupNameRecipient, |
46 | 48 | AssetRecipient, |
47 | 49 | BatchTransformFileExtension, |
48 | 50 | BatchTransformWebSearchGrounding, |
@@ -3789,3 +3791,49 @@ def test_a2a_resource_case_insensitive(self): |
3789 | 3791 | ] |
3790 | 3792 | assert len(a2a_resources) == 1 |
3791 | 3793 | assert isinstance(a2a_resources[0], AgentA2aResourceConfig) |
| 3794 | + |
| 3795 | + |
| 3796 | +class TestArgumentRecipientDeserialization: |
| 3797 | + def test_argument_email_recipient_by_type_int(self): |
| 3798 | + payload = {"type": 7, "argumentName": "assigneeEmail"} |
| 3799 | + recipient: AgentEscalationRecipient = TypeAdapter( |
| 3800 | + AgentEscalationRecipient |
| 3801 | + ).validate_python(payload) |
| 3802 | + assert isinstance(recipient, ArgumentEmailRecipient) |
| 3803 | + assert recipient.argument_path == "assigneeEmail" |
| 3804 | + assert recipient.type == AgentEscalationRecipientType.ARGUMENT_EMAIL |
| 3805 | + |
| 3806 | + def test_argument_group_name_recipient_by_type_int(self): |
| 3807 | + payload = {"type": 8, "argumentName": "assigneeGroup"} |
| 3808 | + recipient: AgentEscalationRecipient = TypeAdapter( |
| 3809 | + AgentEscalationRecipient |
| 3810 | + ).validate_python(payload) |
| 3811 | + assert isinstance(recipient, ArgumentGroupNameRecipient) |
| 3812 | + assert recipient.argument_path == "assigneeGroup" |
| 3813 | + assert recipient.type == AgentEscalationRecipientType.ARGUMENT_GROUP_NAME |
| 3814 | + |
| 3815 | + def test_argument_email_recipient_by_type_string(self): |
| 3816 | + payload = {"type": "ArgumentEmail", "argumentName": "emailArg"} |
| 3817 | + recipient: AgentEscalationRecipient = TypeAdapter( |
| 3818 | + AgentEscalationRecipient |
| 3819 | + ).validate_python(payload) |
| 3820 | + assert isinstance(recipient, ArgumentEmailRecipient) |
| 3821 | + assert recipient.argument_path == "emailArg" |
| 3822 | + |
| 3823 | + def test_argument_group_name_recipient_by_type_string(self): |
| 3824 | + payload = {"type": "ArgumentGroupName", "argumentName": "groupArg"} |
| 3825 | + recipient: AgentEscalationRecipient = TypeAdapter( |
| 3826 | + AgentEscalationRecipient |
| 3827 | + ).validate_python(payload) |
| 3828 | + assert isinstance(recipient, ArgumentGroupNameRecipient) |
| 3829 | + assert recipient.argument_path == "groupArg" |
| 3830 | + |
| 3831 | + def test_argument_email_recipient_missing_argument_name_raises(self): |
| 3832 | + payload = {"type": 7} |
| 3833 | + with pytest.raises(ValidationError): |
| 3834 | + TypeAdapter(AgentEscalationRecipient).validate_python(payload) |
| 3835 | + |
| 3836 | + def test_argument_group_name_recipient_missing_argument_name_raises(self): |
| 3837 | + payload = {"type": 8} |
| 3838 | + with pytest.raises(ValidationError): |
| 3839 | + TypeAdapter(AgentEscalationRecipient).validate_python(payload) |
0 commit comments