51029d4a2d
- test_config.py: GeneralConfig defaults, plugin_settings round-trip - test_config_field.py: ConfigField dataclass, BasePlugin.config_fields() no-op, plugin subclass override - test_config_tui.py: _get/_set_nested, _fid/_pfid helpers, GENERAL_FIELDS validity, ConfigApp general tab rendering, save handler, plugins table, plugin tab visibility, q key exit — using Textual run_test() + Pilot - test_cli.py: auto-setup wizard on first run, skip wizard when config exists, /config in _STATIC_COMMANDS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
from pyra.plugins.base import BasePlugin, ConfigField
|
|
|
|
|
|
def test_config_field_minimal():
|
|
f = ConfigField("mykey", "My Label", "text")
|
|
assert f.key == "mykey"
|
|
assert f.label == "My Label"
|
|
assert f.type == "text"
|
|
assert f.default == ""
|
|
assert f.options == []
|
|
assert f.description == ""
|
|
|
|
|
|
def test_config_field_options_are_independent():
|
|
f1 = ConfigField("k", "L", "select")
|
|
f2 = ConfigField("k", "L", "select")
|
|
f1.options.append("x")
|
|
assert f2.options == [], "options lists must not be shared between instances"
|
|
|
|
|
|
def test_config_field_all_args():
|
|
f = ConfigField("url", "API URL", "select", "http://a.com", ["opt1", "opt2"], "hint text")
|
|
assert f.default == "http://a.com"
|
|
assert f.options == ["opt1", "opt2"]
|
|
assert f.description == "hint text"
|
|
|
|
|
|
def test_config_field_bool_type():
|
|
f = ConfigField("enabled", "Enable feature", "bool", True)
|
|
assert f.type == "bool"
|
|
assert f.default is True
|
|
|
|
|
|
def test_base_plugin_config_fields_returns_empty():
|
|
assert BasePlugin().config_fields() == []
|
|
|
|
|
|
def test_plugin_subclass_config_fields_override():
|
|
class MyPlugin(BasePlugin):
|
|
name = "test"
|
|
description = "test plugin"
|
|
version = "1.0"
|
|
|
|
def config_fields(self):
|
|
return [
|
|
ConfigField("api_url", "API URL", "text", "http://example.com"),
|
|
ConfigField("verify_ssl", "Verify SSL", "bool", True),
|
|
]
|
|
|
|
fields = MyPlugin().config_fields()
|
|
assert len(fields) == 2
|
|
assert fields[0].key == "api_url"
|
|
assert fields[0].type == "text"
|
|
assert fields[1].key == "verify_ssl"
|
|
assert fields[1].type == "bool"
|
|
assert fields[1].default is True
|