|
1 | 1 | import os |
2 | 2 |
|
| 3 | +from typing import get_args |
| 4 | + |
3 | 5 | import pytest |
4 | 6 |
|
5 | 7 | from requests_mock.mocker import Mocker |
6 | 8 |
|
| 9 | +from tagoio_sdk.common.Common_Type import RunTypeOptions |
7 | 10 | from tagoio_sdk.infrastructure.api_request import TagoIORequestError |
8 | 11 | from tagoio_sdk.modules.Resources.Analysis_Types import AnalysisCreateInfo |
9 | 12 | from tagoio_sdk.modules.Resources.Analysis_Types import AnalysisInfo |
@@ -370,3 +373,27 @@ def testAnalysesMethodTryMqttRefused(requests_mock: Mocker) -> None: |
370 | 373 |
|
371 | 374 | with pytest.raises(TagoIORequestError, match="MQTT is off for this Analysis"): |
372 | 375 | 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