piphi-runtime-testkit-python 0.3.0__tar.gz → 0.3.2__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.
Files changed (28) hide show
  1. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/PKG-INFO +5 -1
  2. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/README.md +4 -0
  3. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/pyproject.toml +1 -1
  4. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/__init__.py +4 -0
  5. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/behavior_contract.py +110 -13
  6. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/cross_contract.py +26 -7
  7. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/harness.py +1 -1
  8. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_behavior_contract.py +22 -0
  9. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_runtime_harness.py +16 -3
  10. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_strict_contracts.py +81 -0
  11. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/LICENSE +0 -0
  12. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/assertions.py +0 -0
  13. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/builders.py +0 -0
  14. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/camera.py +0 -0
  15. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/mock_core.py +0 -0
  16. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/pytest_plugin.py +0 -0
  17. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/src/piphi_runtime_testkit_python/waits.py +0 -0
  18. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/__init__.py +0 -0
  19. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_assertions.py +0 -0
  20. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_builders.py +0 -0
  21. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_camera.py +0 -0
  22. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_command_contract.py +0 -0
  23. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_fastapi_runtime_example.py +0 -0
  24. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_mock_core.py +0 -0
  25. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_mock_core_sequences.py +0 -0
  26. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_pytest_plugin.py +0 -0
  27. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_runtime_config_contract.py +0 -0
  28. {piphi_runtime_testkit_python-0.3.0 → piphi_runtime_testkit_python-0.3.2}/tests/test_runtime_flow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: piphi-runtime-testkit-python
3
- Version: 0.3.0
3
+ Version: 0.3.2
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "piphi-runtime-testkit-python"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Pytest-first helpers for testing PiPhi runtime integrations"
5
5
  authors = [
6
6
  { name = "KelvinSan", email = "support@piphi.network" },
@@ -32,6 +32,8 @@ from .camera import (
32
32
  from .behavior_contract import (
33
33
  BehaviorTelemetryIssue,
34
34
  assert_behavior_conditions_match_telemetry,
35
+ assert_behavior_conditions_match_state,
36
+ find_behavior_state_issues,
35
37
  find_behavior_telemetry_issues,
36
38
  )
37
39
  from .mock_core import CapturedRequest, MockCoreServer, RUNTIME_CONFIG_FETCH_PATH
@@ -77,6 +79,7 @@ __all__ = [
77
79
  "assert_onboarding_declaration",
78
80
  "assert_camera_capability",
79
81
  "assert_behavior_conditions_match_telemetry",
82
+ "assert_behavior_conditions_match_state",
80
83
  "assert_event_sent",
81
84
  "assert_event_payload",
82
85
  "assert_never_event",
@@ -95,6 +98,7 @@ __all__ = [
95
98
  "build_core_config_row",
96
99
  "build_runtime_headers",
97
100
  "find_behavior_telemetry_issues",
101
+ "find_behavior_state_issues",
98
102
  "wait_for_event",
99
103
  "wait_for_request",
100
104
  "wait_for_telemetry",
@@ -1,4 +1,4 @@
1
- """Conformance checks between automation behaviors and emitted telemetry."""
1
+ """Conformance checks between automation behaviors and runtime observations."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -9,7 +9,7 @@ from typing import Any
9
9
 
10
10
  @dataclass(frozen=True)
11
11
  class BehaviorTelemetryIssue:
12
- """One behavior condition that cannot be evaluated from runtime telemetry."""
12
+ """One behavior condition that cannot be evaluated from runtime samples."""
13
13
 
14
14
  device_id: str
15
15
  condition_id: str
@@ -55,6 +55,46 @@ def _metric_samples(
55
55
  return samples
56
56
 
57
57
 
58
+ def _runtime_state_samples(
59
+ state_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any],
60
+ ) -> list[Mapping[str, Any]]:
61
+ raw_samples = (
62
+ [state_samples] if isinstance(state_samples, Mapping) else list(state_samples)
63
+ )
64
+ samples: list[Mapping[str, Any]] = []
65
+
66
+ def append_state(value: Any) -> None:
67
+ state = _as_mapping(value)
68
+ if not state:
69
+ return
70
+ nested_state = state.get("state")
71
+ if isinstance(nested_state, Mapping):
72
+ state = nested_state
73
+ samples.append(state)
74
+ components = state.get("components")
75
+ if isinstance(components, Mapping):
76
+ samples.extend(
77
+ component for component in components.values() if isinstance(component, Mapping)
78
+ )
79
+ else:
80
+ samples.extend(
81
+ component
82
+ for component in _as_list(components)
83
+ if isinstance(component, Mapping)
84
+ )
85
+
86
+ for raw_sample in raw_samples:
87
+ payload = _as_mapping(raw_sample)
88
+ entries = payload.get("entries")
89
+ if isinstance(entries, (list, tuple)):
90
+ for entry in entries:
91
+ mapped_entry = _as_mapping(entry)
92
+ append_state(mapped_entry.get("latest_state", mapped_entry))
93
+ else:
94
+ append_state(payload.get("latest_state", payload))
95
+ return samples
96
+
97
+
58
98
  def _field_aliases(runtime: Mapping[str, Any]) -> tuple[str, ...]:
59
99
  raw_aliases = runtime.get("fieldAliases", runtime.get("field_aliases"))
60
100
  return tuple(
@@ -85,6 +125,7 @@ def _condition_issue(
85
125
  device_id: str,
86
126
  samples: list[Mapping[str, Any]],
87
127
  dynamic_condition_ids: set[str],
128
+ sample_kind: str = "telemetry",
88
129
  template_id: str | None = None,
89
130
  ) -> BehaviorTelemetryIssue | None:
90
131
  condition_id = str(condition.get("id") or condition.get("field") or "condition").strip()
@@ -134,7 +175,7 @@ def _condition_issue(
134
175
  condition_id=condition_id,
135
176
  field=field,
136
177
  aliases=aliases,
137
- reason="field was not emitted by any representative telemetry sample",
178
+ reason=f"field was not emitted by any representative {sample_kind} sample",
138
179
  template_id=template_id,
139
180
  )
140
181
 
@@ -169,20 +210,13 @@ def _condition_leaves(node: Any) -> Iterable[Mapping[str, Any]]:
169
210
  yield current
170
211
 
171
212
 
172
- def find_behavior_telemetry_issues(
213
+ def _find_behavior_sample_issues(
173
214
  behaviors: Mapping[str, Any],
174
- telemetry_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any],
215
+ samples: list[Mapping[str, Any]],
175
216
  *,
176
217
  dynamic_condition_ids: Iterable[str] = (),
218
+ sample_kind: str,
177
219
  ) -> list[BehaviorTelemetryIssue]:
178
- """Return conditions that representative runtime telemetry cannot evaluate.
179
-
180
- ``telemetry_samples`` may contain raw metric mappings or Core telemetry
181
- payloads with a ``metrics`` object. Parameter-driven dynamic conditions must
182
- be named explicitly in ``dynamic_condition_ids`` and tested separately.
183
- """
184
-
185
- samples = _metric_samples(telemetry_samples)
186
220
  dynamic_ids = {
187
221
  str(condition_id or "").strip()
188
222
  for condition_id in dynamic_condition_ids
@@ -216,6 +250,7 @@ def find_behavior_telemetry_issues(
216
250
  device_id=device_id,
217
251
  samples=samples,
218
252
  dynamic_condition_ids=dynamic_ids,
253
+ sample_kind=sample_kind,
219
254
  )
220
255
  if issue:
221
256
  issues.append(issue)
@@ -245,6 +280,7 @@ def find_behavior_telemetry_issues(
245
280
  device_id=device_id,
246
281
  samples=samples,
247
282
  dynamic_condition_ids=dynamic_ids,
283
+ sample_kind=sample_kind,
248
284
  template_id=template_id,
249
285
  )
250
286
  if issue:
@@ -252,6 +288,47 @@ def find_behavior_telemetry_issues(
252
288
  return issues
253
289
 
254
290
 
291
+ def find_behavior_telemetry_issues(
292
+ behaviors: Mapping[str, Any],
293
+ telemetry_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any],
294
+ *,
295
+ dynamic_condition_ids: Iterable[str] = (),
296
+ ) -> list[BehaviorTelemetryIssue]:
297
+ """Return conditions that representative runtime telemetry cannot evaluate.
298
+
299
+ ``telemetry_samples`` may contain raw metric mappings or Core telemetry
300
+ payloads with a ``metrics`` object. Parameter-driven dynamic conditions must
301
+ be named explicitly in ``dynamic_condition_ids`` and tested separately.
302
+ """
303
+
304
+ return _find_behavior_sample_issues(
305
+ behaviors,
306
+ _metric_samples(telemetry_samples),
307
+ dynamic_condition_ids=dynamic_condition_ids,
308
+ sample_kind="telemetry",
309
+ )
310
+
311
+
312
+ def find_behavior_state_issues(
313
+ behaviors: Mapping[str, Any],
314
+ state_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any],
315
+ *,
316
+ dynamic_condition_ids: Iterable[str] = (),
317
+ ) -> list[BehaviorTelemetryIssue]:
318
+ """Return state-backed conditions absent from representative runtime state.
319
+
320
+ Samples may be individual state mappings or a runtime ``/state`` response
321
+ containing ``entries`` with ``latest_state`` and nested ``components``.
322
+ """
323
+
324
+ return _find_behavior_sample_issues(
325
+ behaviors,
326
+ _runtime_state_samples(state_samples),
327
+ dynamic_condition_ids=dynamic_condition_ids,
328
+ sample_kind="state",
329
+ )
330
+
331
+
255
332
  def assert_behavior_conditions_match_telemetry(
256
333
  behaviors: Mapping[str, Any],
257
334
  telemetry_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any],
@@ -270,3 +347,23 @@ def assert_behavior_conditions_match_telemetry(
270
347
  raise AssertionError(
271
348
  "Behavior conditions do not match emitted telemetry:\n" + details
272
349
  )
350
+
351
+
352
+ def assert_behavior_conditions_match_state(
353
+ behaviors: Mapping[str, Any],
354
+ state_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any],
355
+ *,
356
+ dynamic_condition_ids: Iterable[str] = (),
357
+ ) -> None:
358
+ """Fail when advertised state-backed conditions lack representative state."""
359
+
360
+ issues = find_behavior_state_issues(
361
+ behaviors,
362
+ state_samples,
363
+ dynamic_condition_ids=dynamic_condition_ids,
364
+ )
365
+ if issues:
366
+ details = "\n".join(f"- {issue.describe()}" for issue in issues)
367
+ raise AssertionError(
368
+ "Behavior conditions do not match representative runtime state:\n" + details
369
+ )
@@ -1,10 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections.abc import Mapping, Set
3
+ from collections.abc import Iterable, Mapping, Set
4
4
  from typing import Any
5
5
 
6
6
  from .assertions import assert_entities_response
7
- from .behavior_contract import assert_behavior_conditions_match_telemetry
7
+ from .behavior_contract import (
8
+ assert_behavior_conditions_match_state,
9
+ assert_behavior_conditions_match_telemetry,
10
+ )
8
11
 
9
12
 
10
13
  def _mapping_keys(value: Any) -> set[str]:
@@ -18,10 +21,15 @@ def assert_cross_contract(
18
21
  behaviors: Mapping[str, Any],
19
22
  exercised_commands: Set[str],
20
23
  captured_event_types: Set[str],
21
- telemetry_samples: list[Mapping[str, Any]] | None = None,
24
+ telemetry_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any] | None = None,
25
+ state_samples: Iterable[Mapping[str, Any]] | Mapping[str, Any] | None = None,
22
26
  dynamic_condition_ids: Set[str] = frozenset(),
23
27
  ) -> None:
24
- """Check manifest, runtime, behaviors, and observed execution as one contract."""
28
+ """Check manifest, runtime, behaviors, and observed execution as one contract.
29
+
30
+ State samples take precedence for state-backed behavior conditions. Existing
31
+ telemetry-only callers retain the legacy validation path.
32
+ """
25
33
 
26
34
  assert_entities_response(runtime_entities, strict=True)
27
35
  manifest_capabilities = _mapping_keys(manifest.get("capabilities"))
@@ -63,9 +71,16 @@ def assert_cross_contract(
63
71
  for device in behaviors.get("devices", [])
64
72
  )
65
73
  if has_conditions:
66
- if telemetry_samples is None:
67
- issues.append("behavior conditions were advertised but no telemetry samples were supplied")
68
- else:
74
+ if state_samples is not None:
75
+ try:
76
+ assert_behavior_conditions_match_state(
77
+ behaviors,
78
+ state_samples,
79
+ dynamic_condition_ids=dynamic_condition_ids,
80
+ )
81
+ except AssertionError as exc:
82
+ issues.append(str(exc))
83
+ elif telemetry_samples is not None:
69
84
  try:
70
85
  assert_behavior_conditions_match_telemetry(
71
86
  behaviors,
@@ -74,5 +89,9 @@ def assert_cross_contract(
74
89
  )
75
90
  except AssertionError as exc:
76
91
  issues.append(str(exc))
92
+ else:
93
+ issues.append(
94
+ "behavior conditions were advertised but no state or telemetry samples were supplied"
95
+ )
77
96
  if issues:
78
97
  raise AssertionError("Cross-contract conformance failed:\n- " + "\n- ".join(issues))
@@ -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["request_id"] = request_id
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:
@@ -3,6 +3,7 @@ import pytest
3
3
  from piphi_runtime_testkit_python import (
4
4
  CapturedRequest,
5
5
  MockCoreServer,
6
+ assert_behavior_conditions_match_state,
6
7
  assert_behavior_conditions_match_telemetry,
7
8
  find_behavior_telemetry_issues,
8
9
  )
@@ -61,6 +62,27 @@ def test_behavior_conditions_accept_fields_aliases_types_and_templates() -> None
61
62
  )
62
63
 
63
64
 
65
+ def test_behavior_conditions_accept_nested_runtime_state_components() -> None:
66
+ assert_behavior_conditions_match_state(
67
+ _behaviors(),
68
+ {
69
+ "entries": [{
70
+ "config_id": "shelly-kitchen",
71
+ "latest_state": {
72
+ "connected": True,
73
+ "components": [{
74
+ "key": "switch:0",
75
+ "type": "switch",
76
+ "channel": 0,
77
+ "power_state": True,
78
+ "brightness": 42,
79
+ }],
80
+ },
81
+ }],
82
+ },
83
+ )
84
+
85
+
64
86
  def test_behavior_conditions_report_missing_field_and_type_mismatch() -> None:
65
87
  issues = find_behavior_telemetry_issues(
66
88
  _behaviors(),
@@ -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")
@@ -138,3 +138,84 @@ def test_cross_contract_requires_every_behavior_action_and_trigger_to_be_exercis
138
138
  exercised_commands=set(),
139
139
  captured_event_types={"runtime.config.applied"},
140
140
  )
141
+
142
+
143
+ def test_cross_contract_validates_shelly_condition_from_runtime_state() -> None:
144
+ capabilities = {"on": {"kind": "sensor", "unit": "bool"}}
145
+ entities = {
146
+ "entities": [{
147
+ "id": "shelly-aabbccddeeff:switch:0",
148
+ "name": "Switch 0",
149
+ "config_id": "shelly-kitchen",
150
+ "device_id": "shelly-aabbccddeeff",
151
+ "capabilities": ["on"],
152
+ "available_commands": [],
153
+ }],
154
+ "capabilities": capabilities,
155
+ "commands": {},
156
+ }
157
+ behaviors = {"devices": [{
158
+ "id": "shelly_device",
159
+ "capabilities": ["on"],
160
+ "conditions": [{
161
+ "id": "switch_is_on",
162
+ "type": "boolean",
163
+ "runtime": {"source": "state", "field": "on"},
164
+ }],
165
+ }]}
166
+ state_response = {
167
+ "entries": [{
168
+ "config_id": "shelly-kitchen",
169
+ "device_id": "shelly-aabbccddeeff",
170
+ "latest_state": {
171
+ "connected": True,
172
+ "components": [{
173
+ "key": "switch:0",
174
+ "type": "switch",
175
+ "channel": 0,
176
+ "on": True,
177
+ }],
178
+ },
179
+ }],
180
+ }
181
+
182
+ assert_cross_contract(
183
+ manifest={"capabilities": capabilities, "commands": {}},
184
+ runtime_entities=entities,
185
+ behaviors=behaviors,
186
+ exercised_commands=set(),
187
+ captured_event_types=set(),
188
+ telemetry_samples={"metrics": {"switch_0_power_w": 4.2}},
189
+ state_samples=state_response,
190
+ )
191
+
192
+ with pytest.raises(AssertionError, match="representative state sample"):
193
+ assert_cross_contract(
194
+ manifest={"capabilities": capabilities, "commands": {}},
195
+ runtime_entities=entities,
196
+ behaviors=behaviors,
197
+ exercised_commands=set(),
198
+ captured_event_types=set(),
199
+ state_samples={"entries": [{"latest_state": {"components": []}}]},
200
+ )
201
+
202
+
203
+ def test_cross_contract_retains_telemetry_sample_compatibility() -> None:
204
+ behaviors = {"devices": [{
205
+ "id": "device",
206
+ "capabilities": ["connected"],
207
+ "conditions": [{
208
+ "id": "is_connected",
209
+ "type": "boolean",
210
+ "runtime": {"source": "state", "field": "connected"},
211
+ }],
212
+ }]}
213
+
214
+ assert_cross_contract(
215
+ manifest={"capabilities": CAPABILITIES, "commands": COMMANDS},
216
+ runtime_entities=ENTITIES,
217
+ behaviors=behaviors,
218
+ exercised_commands=set(),
219
+ captured_event_types=set(),
220
+ telemetry_samples={"metrics": {"connected": True}},
221
+ )