|
15 | 15 |
|
16 | 16 | CUSTOM_REFRESH_RATE = 10.0 |
17 | 17 | CUSTOM_AUDIT_RATE = 0.0 |
| 18 | +REFRESH_RATE_SECONDS = 15.0 |
18 | 19 |
|
19 | 20 |
|
20 | 21 | def _make_detector(detector_id: str) -> Detector: |
@@ -178,30 +179,34 @@ def test_detectors_config_to_payload_shape(): |
178 | 179 |
|
179 | 180 | def test_edge_endpoint_config_accepts_top_level_payload_shape(): |
180 | 181 | """Accepts the top-level edge endpoint payload shape used by APIs.""" |
181 | | - config = EdgeEndpointConfig.model_validate({ |
182 | | - "global_config": {"refresh_rate": CUSTOM_REFRESH_RATE}, |
183 | | - "edge_inference_configs": {"default": {"enabled": True}}, |
184 | | - "detectors": [{"detector_id": "det_1", "edge_inference_config": "default"}], |
185 | | - }) |
| 182 | + config = EdgeEndpointConfig.model_validate( |
| 183 | + { |
| 184 | + "global_config": {"refresh_rate": CUSTOM_REFRESH_RATE}, |
| 185 | + "edge_inference_configs": {"default": {"enabled": True}}, |
| 186 | + "detectors": [{"detector_id": "det_1", "edge_inference_config": "default"}], |
| 187 | + } |
| 188 | + ) |
186 | 189 |
|
187 | 190 | assert config.global_config.refresh_rate == CUSTOM_REFRESH_RATE |
188 | 191 | assert [detector.detector_id for detector in config.detectors] == ["det_1"] |
189 | 192 |
|
190 | 193 |
|
191 | 194 | def test_edge_endpoint_config_from_yaml_accepts_yaml_text(): |
192 | 195 | """Parses edge-endpoint YAML text using EdgeEndpointConfig.from_yaml.""" |
193 | | - config = EdgeEndpointConfig.from_yaml(yaml_str=""" |
| 196 | + config = EdgeEndpointConfig.from_yaml( |
| 197 | + yaml_str=f""" |
194 | 198 | global_config: |
195 | | - refresh_rate: 15.0 |
| 199 | + refresh_rate: {REFRESH_RATE_SECONDS} |
196 | 200 | edge_inference_configs: |
197 | 201 | default: |
198 | 202 | enabled: true |
199 | 203 | detectors: |
200 | 204 | - detector_id: det_1 |
201 | 205 | edge_inference_config: default |
202 | | - """) |
| 206 | + """ |
| 207 | + ) |
203 | 208 |
|
204 | | - assert config.global_config.refresh_rate == 15.0 |
| 209 | + assert config.global_config.refresh_rate == REFRESH_RATE_SECONDS |
205 | 210 | assert [detector.detector_id for detector in config.detectors] == ["det_1"] |
206 | 211 |
|
207 | 212 |
|
@@ -272,14 +277,14 @@ def test_edge_endpoint_config_from_payload_round_trip(): |
272 | 277 | def test_edge_endpoint_config_from_payload_accepts_literal_payload(): |
273 | 278 | """Constructs EdgeEndpointConfig from a literal payload dictionary.""" |
274 | 279 | payload = { |
275 | | - "global_config": {"refresh_rate": 15.0}, |
| 280 | + "global_config": {"refresh_rate": REFRESH_RATE_SECONDS}, |
276 | 281 | "edge_inference_configs": {"default": {"enabled": True}}, |
277 | 282 | "detectors": [{"detector_id": "det_1", "edge_inference_config": "default"}], |
278 | 283 | } |
279 | 284 |
|
280 | 285 | config = EdgeEndpointConfig.from_payload(payload) |
281 | 286 |
|
282 | | - assert config.global_config.refresh_rate == 15.0 |
| 287 | + assert config.global_config.refresh_rate == REFRESH_RATE_SECONDS |
283 | 288 | assert config.edge_inference_configs["default"].name == "default" |
284 | 289 | assert [detector.detector_id for detector in config.detectors] == ["det_1"] |
285 | 290 |
|
|
0 commit comments