test: add RED test for config schema advanced flags (TDD checkpoint)
Adds test_config_schema.py verifying every visible field has an explicit 'advanced' bool, basic fields are advanced=False, and sampled advanced fields are advanced=True.
This commit is contained in:
89
backend/tests/adapters/arma3/test_config_schema.py
Normal file
89
backend/tests/adapters/arma3/test_config_schema.py
Normal file
@@ -0,0 +1,89 @@
|
||||
"""Tests for Arma3ConfigGenerator.get_ui_schema() — advanced flag completeness."""
|
||||
import pytest
|
||||
from adapters.arma3.config_generator import Arma3ConfigGenerator
|
||||
|
||||
BASIC_FIELDS = {
|
||||
"server": {
|
||||
"hostname", "max_players", "password", "password_admin",
|
||||
"motd_lines", "motd_interval",
|
||||
"forced_difficulty", "auto_select_mission", "random_mission_order",
|
||||
"persistent", "skip_lobby", "drawing_in_map",
|
||||
"battleye", "verify_signatures", "allowed_file_patching",
|
||||
"disable_von", "von_codec",
|
||||
},
|
||||
"profile": {
|
||||
"group_indicators", "friendly_tags", "enemy_tags",
|
||||
"commands", "waypoints", "weapon_info", "stance_indicator",
|
||||
"ai_level_preset", "skill_ai", "precision_ai",
|
||||
},
|
||||
"rcon": {"rcon_password", "enabled"},
|
||||
}
|
||||
|
||||
ADVANCED_SAMPLES = {
|
||||
"server": {
|
||||
"server_command_password", "kick_duplicate", "vote_threshold",
|
||||
"max_ping", "max_packet_loss", "disconnect_timeout",
|
||||
"kick_on_ping", "log_file", "upnp", "loopback",
|
||||
"admin_uids", "headless_clients", "local_clients",
|
||||
"default_mission_params",
|
||||
},
|
||||
"basic": {
|
||||
"min_bandwidth", "max_bandwidth", "max_msg_send",
|
||||
"max_size_guaranteed", "min_error_to_send",
|
||||
},
|
||||
"profile": {
|
||||
"reduced_damage", "tactical_ping", "weapon_crosshair",
|
||||
"vision_aid", "third_person_view", "score_table",
|
||||
"death_messages", "von_id",
|
||||
},
|
||||
"launch": {
|
||||
"world", "limit_fps", "cpu_count", "max_mem",
|
||||
"enable_ht", "huge_pages", "no_logs", "netlog",
|
||||
},
|
||||
"rcon": {"max_ping"},
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def schema():
|
||||
return Arma3ConfigGenerator().get_ui_schema()
|
||||
|
||||
|
||||
def test_every_visible_field_has_advanced_key(schema):
|
||||
"""Every non-hidden field must carry an explicit `advanced` bool."""
|
||||
for section, fields in schema.items():
|
||||
for field, entry in fields.items():
|
||||
if entry.get("widget") == "hidden":
|
||||
continue
|
||||
assert "advanced" in entry, (
|
||||
f"section={section!r} field={field!r} is missing 'advanced' key"
|
||||
)
|
||||
|
||||
|
||||
def test_basic_fields_are_not_advanced(schema):
|
||||
"""Confirmed basic fields must have advanced=False."""
|
||||
for section, field_names in BASIC_FIELDS.items():
|
||||
for field in field_names:
|
||||
entry = schema[section][field]
|
||||
assert entry["advanced"] is False, (
|
||||
f"section={section!r} field={field!r} should be basic (advanced=False)"
|
||||
)
|
||||
|
||||
|
||||
def test_advanced_samples_are_marked_advanced(schema):
|
||||
"""Sampled advanced fields must have advanced=True."""
|
||||
for section, field_names in ADVANCED_SAMPLES.items():
|
||||
for field in field_names:
|
||||
entry = schema[section][field]
|
||||
assert entry["advanced"] is True, (
|
||||
f"section={section!r} field={field!r} should be advanced (advanced=True)"
|
||||
)
|
||||
|
||||
|
||||
def test_hidden_fields_excluded_from_advanced_requirement(schema):
|
||||
"""Hidden fields (e.g. missions) are exempt from the advanced check."""
|
||||
for section, fields in schema.items():
|
||||
for field, entry in fields.items():
|
||||
if entry.get("widget") == "hidden":
|
||||
# No advanced key required — just confirm widget is hidden
|
||||
assert entry["widget"] == "hidden"
|
||||
Reference in New Issue
Block a user