Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/test_ai_scriptless_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
CommandContract,
command_contract,
empty_mandatory_note,
handset_constant_note,
validate_argument_names,
)

Expand Down Expand Up @@ -89,6 +90,43 @@ def test_accepts_variable_data_source_form(self):
) is None


class TestHandsetConstantNote:
HANDSET_COMMAND = CommandContract(
"handset_ready",
mandatory=frozenset({"handsetId"}),
parameters={"handsetId": ParameterContract(
name="handsetId", data_type="HANDSET", mandatory=True,
data_sources=("CONSTANT", "VARIABLE", "DATATABLE"))},
element_type="Action",
)

def test_notes_a_device_pinned_to_a_literal_id(self):
note = handset_constant_note(
"handset_ready",
{"handsetId": {"data_source": "CONSTANT", "value": "DEVICE-123"}},
self.HANDSET_COMMAND,
)
assert "handsetId" in note
assert "No handset is available" in note

def test_no_note_when_bound_to_a_device_variable(self):
assert handset_constant_note(
"handset_ready",
{"handsetId": {"data_source": "VARIABLE", "value": "android"}},
self.HANDSET_COMMAND,
) is None

def test_no_note_for_a_constant_on_another_parameter_type(self):
contract = CommandContract(
"type",
parameters={"text": ParameterContract(name="text", data_type="STRING")},
element_type="Action",
)
assert handset_constant_note(
"type", {"text": {"data_source": "CONSTANT", "value": "hello"}}, contract
) is None


class TestEmptyMandatoryNote:
def test_notes_mandatory_left_empty_by_spec_default(self):
note = empty_mandatory_note("ai_user-action", None, USER_ACTION)
Expand Down
Loading