piphi-runtime-testkit-python 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/PKG-INFO +5 -1
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/README.md +4 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/pyproject.toml +1 -1
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/harness.py +1 -1
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_runtime_harness.py +16 -3
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/LICENSE +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/__init__.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/assertions.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/behavior_contract.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/builders.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/camera.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/cross_contract.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/mock_core.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/pytest_plugin.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/src/piphi_runtime_testkit_python/waits.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/__init__.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_assertions.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_behavior_contract.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_builders.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_camera.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_command_contract.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_fastapi_runtime_example.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_mock_core.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_mock_core_sequences.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_pytest_plugin.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_runtime_config_contract.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_runtime_flow.py +0 -0
- {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_strict_contracts.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: piphi-runtime-testkit-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Pytest-first helpers for testing PiPhi runtime integrations
|
|
5
5
|
Keywords: piphi,pytest,testing,runtime,iot
|
|
6
6
|
Author-Email: KelvinSan <support@piphi.network>
|
|
@@ -89,6 +89,10 @@ Pass an app factory instead of an app to make `await harness.restart()` create a
|
|
|
89
89
|
fresh process-local runtime. Use `RuntimeHarness.for_http(...)` for a running
|
|
90
90
|
container or process without changing scenario code.
|
|
91
91
|
|
|
92
|
+
For a canonical on-demand state read, call
|
|
93
|
+
`await harness.state(refresh=True, request_id="refresh-1")`. The harness maps
|
|
94
|
+
that argument to the runtime boundary's `refresh_request_id` query parameter.
|
|
95
|
+
|
|
92
96
|
The profiles are intentionally small and readable:
|
|
93
97
|
|
|
94
98
|
- `basic`: health, auth rejection, config, entities, and deconfigure
|
|
@@ -65,6 +65,10 @@ Pass an app factory instead of an app to make `await harness.restart()` create a
|
|
|
65
65
|
fresh process-local runtime. Use `RuntimeHarness.for_http(...)` for a running
|
|
66
66
|
container or process without changing scenario code.
|
|
67
67
|
|
|
68
|
+
For a canonical on-demand state read, call
|
|
69
|
+
`await harness.state(refresh=True, request_id="refresh-1")`. The harness maps
|
|
70
|
+
that argument to the runtime boundary's `refresh_request_id` query parameter.
|
|
71
|
+
|
|
68
72
|
The profiles are intentionally small and readable:
|
|
69
73
|
|
|
70
74
|
- `basic`: health, auth rejection, config, entities, and deconfigure
|
|
@@ -214,7 +214,7 @@ class RuntimeHarness:
|
|
|
214
214
|
async def state(self, *, refresh: bool = False, request_id: str | None = None) -> RuntimeResponse:
|
|
215
215
|
params: dict[str, Any] = {"refresh": "true"} if refresh else {}
|
|
216
216
|
if request_id:
|
|
217
|
-
params["
|
|
217
|
+
params["refresh_request_id"] = request_id
|
|
218
218
|
return await self.request("GET", self.endpoints["state"], params=params)
|
|
219
219
|
|
|
220
220
|
async def command(self, payload: CommandPayload | Mapping[str, Any]) -> RuntimeResponse:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from fastapi import FastAPI, Header, HTTPException
|
|
3
|
+
from fastapi import FastAPI, Header, HTTPException, Request
|
|
4
4
|
import pytest
|
|
5
5
|
|
|
6
6
|
from piphi_runtime_testkit_python import (
|
|
@@ -44,8 +44,8 @@ def runtime_factory() -> FastAPI:
|
|
|
44
44
|
return {"entities": [{"id": key, "name": key, "config_id": key, "device_id": key, "capabilities": ["refresh"], "available_commands": ["refresh"]} for key in configs], "capabilities": {"refresh": {"kind": "action"}}, "commands": {"refresh": {}}}
|
|
45
45
|
|
|
46
46
|
@app.get("/state")
|
|
47
|
-
async def state():
|
|
48
|
-
return {"entries": configs}
|
|
47
|
+
async def state(request: Request):
|
|
48
|
+
return {"entries": configs, "query": dict(request.query_params)}
|
|
49
49
|
|
|
50
50
|
@app.post("/command")
|
|
51
51
|
async def command(payload: dict):
|
|
@@ -81,6 +81,19 @@ async def test_runtime_harness_exercises_asgi_lifecycle_and_restart() -> None:
|
|
|
81
81
|
assert (await harness.entities()).json["entities"] == []
|
|
82
82
|
|
|
83
83
|
|
|
84
|
+
@pytest.mark.asyncio
|
|
85
|
+
async def test_state_maps_request_id_argument_to_canonical_refresh_request_id_query() -> None:
|
|
86
|
+
harness = RuntimeHarness.for_asgi(runtime_factory)
|
|
87
|
+
|
|
88
|
+
async with harness:
|
|
89
|
+
response = await harness.state(refresh=True, request_id="refresh-123")
|
|
90
|
+
|
|
91
|
+
assert response.json["query"] == {
|
|
92
|
+
"refresh": "true",
|
|
93
|
+
"refresh_request_id": "refresh-123",
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
84
97
|
@pytest.mark.asyncio
|
|
85
98
|
async def test_profiles_return_readable_checks_instead_of_hiding_failures() -> None:
|
|
86
99
|
config = build_config_payload(config_id="device-1", container_id="runtime-1")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_assertions.py
RENAMED
|
File without changes
|
|
File without changes
|
{piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_builders.py
RENAMED
|
File without changes
|
{piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_camera.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_mock_core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.1}/tests/test_runtime_flow.py
RENAMED
|
File without changes
|
|
File without changes
|