Skip to content

Commit a1ff209

Browse files
committed
feat(resources): add the Luau runtime to the runtime options
Add luau-rt2026, the Luau Sandbox runtime, to RunTypeOptions so a Luau Analysis can be created with its MQTT Endpoint on.
1 parent d315ab0 commit a1ff209

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

‎docs/source/common/Common_Type.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ Conditionals
4848
RunTypeOptions
4949
----------------
5050

51-
| **RunTypeOptions**: Literal["node-legacy", "python-legacy", "node-rt2025", "python-rt2025", "deno-rt2025"]
51+
| **RunTypeOptions**: Literal["node-legacy", "python-legacy", "node-rt2025", "python-rt2025", "deno-rt2025", "luau-rt2026"]
52+
| ``luau-rt2026`` is the Luau Sandbox runtime; it runs on TagoIO only.
5253
5354
.. _TokenCreateResponse:
5455

‎src/tagoio_sdk/common/Common_Type.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@
2020

2121
Conditionals = Literal["<", ">", "=", "!", "><", "*"]
2222

23-
RunTypeOptions = Literal["node-legacy", "python-legacy", "node-rt2025", "python-rt2025", "deno-rt2025"]
23+
RunTypeOptions = Literal[
24+
"node-legacy",
25+
"python-legacy",
26+
"node-rt2025",
27+
"python-rt2025",
28+
"deno-rt2025",
29+
"luau-rt2026",
30+
]
31+
"""Analysis runtimes. luau-rt2026 is the Luau Sandbox runtime; it runs on TagoIO only."""
2432

2533

2634
class TokenCreateResponse(TypedDict):

‎tests/Resources/test_analyses.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import os
22

3+
from typing import get_args
4+
35
import pytest
46

57
from requests_mock.mocker import Mocker
68

9+
from tagoio_sdk.common.Common_Type import RunTypeOptions
710
from tagoio_sdk.infrastructure.api_request import TagoIORequestError
811
from tagoio_sdk.modules.Resources.Analysis_Types import AnalysisCreateInfo
912
from tagoio_sdk.modules.Resources.Analysis_Types import AnalysisInfo
@@ -370,3 +373,27 @@ def testAnalysesMethodTryMqttRefused(requests_mock: Mocker) -> None:
370373

371374
with pytest.raises(TagoIORequestError, match="MQTT is off for this Analysis"):
372375
resources.analysis.tryMqtt("analysis_id", {"topic": "sensors/42", "payload": "on"})
376+
377+
378+
def testRunTypeOptionsIncludesLuau() -> None:
379+
assert "luau-rt2026" in get_args(RunTypeOptions)
380+
381+
382+
def testAnalysesMethodCreateLuauWithMqtt(requests_mock: Mocker) -> None:
383+
"""
384+
:param requests_mock are a plugin of pytest to mock the requests.
385+
"""
386+
requests_mock.post("https://api.tago.io/analysis", json=mockCreateAnalysis())
387+
388+
analysis_data = AnalysisCreateInfo(
389+
name="Sensors MQTT", runtime="luau-rt2026", mqtt={"active": True}
390+
)
391+
resources = Resources()
392+
response = resources.analysis.create(analysis_data)
393+
394+
assert response == mockCreateAnalysis()["result"]
395+
assert requests_mock.last_request.json() == {
396+
"name": "Sensors MQTT",
397+
"runtime": "luau-rt2026",
398+
"mqtt": {"active": True},
399+
}

0 commit comments

Comments
 (0)