phase 12
This commit is contained in:
44
tests/detect/test_config_endpoint.py
Normal file
44
tests/detect/test_config_endpoint.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Tests for the config endpoint and stage palette."""
|
||||
|
||||
from detect.stages import list_stages, get_palette
|
||||
|
||||
|
||||
def test_stage_palette_has_config_fields():
|
||||
"""Every stage with config fields should be servable by the endpoint."""
|
||||
stages = list_stages()
|
||||
stages_with_config = [s for s in stages if s.config_fields]
|
||||
|
||||
assert len(stages_with_config) > 0
|
||||
|
||||
for stage in stages_with_config:
|
||||
for field in stage.config_fields:
|
||||
assert field.name
|
||||
assert field.type
|
||||
assert field.default is not None or field.type == "bool"
|
||||
|
||||
|
||||
def test_palette_categories():
|
||||
palette = get_palette()
|
||||
|
||||
expected_categories = {"preprocessing", "detection", "resolution", "escalation", "output"}
|
||||
actual_categories = set(palette.keys())
|
||||
|
||||
assert actual_categories == expected_categories
|
||||
|
||||
|
||||
def test_stage_config_serializable():
|
||||
"""Config fields should be JSON-serializable for the API response."""
|
||||
import json
|
||||
|
||||
stages = list_stages()
|
||||
for stage in stages:
|
||||
data = {
|
||||
"name": stage.name,
|
||||
"label": stage.label,
|
||||
"config_fields": [
|
||||
{"name": f.name, "type": f.type, "default": f.default}
|
||||
for f in stage.config_fields
|
||||
],
|
||||
}
|
||||
json_str = json.dumps(data)
|
||||
assert len(json_str) > 0
|
||||
Reference in New Issue
Block a user