Some checks failed
Architecture Lint / Linter Tests (pull_request) Successful in 9s
PR Checklist / pr-checklist (pull_request) Failing after 1m9s
Validate Config / JSON Validate (pull_request) Successful in 5s
Smoke Test / smoke (pull_request) Failing after 6s
Validate Config / YAML Lint (pull_request) Failing after 5s
Validate Config / Cron Syntax Check (pull_request) Successful in 3s
Validate Config / Deploy Script Dry Run (pull_request) Successful in 3s
Validate Config / Playbook Schema Validation (pull_request) Successful in 5s
Validate Config / Python Syntax & Import Check (pull_request) Failing after 12s
Validate Config / Shell Script Lint (pull_request) Failing after 12s
Architecture Lint / Lint Repository (pull_request) Has been cancelled
Validate Config / Python Test Suite (pull_request) Has been cancelled
Part of #690
73 lines
1.9 KiB
Python
73 lines
1.9 KiB
Python
"""Tests for config validation (#690)."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from scripts.config_validate import validate_config, ValidationError
|
|
|
|
|
|
def test_valid_config():
|
|
content = "model: gpt-4\nprovider: openai\n"
|
|
valid, errors = validate_config(content)
|
|
assert valid
|
|
assert len(errors) == 0
|
|
|
|
|
|
def test_missing_required_key():
|
|
content = "provider: openai\n"
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
assert any("model" in e.path for e in errors)
|
|
|
|
|
|
def test_wrong_type():
|
|
content = "model: 123\n"
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
assert any("model" in e.path for e in errors)
|
|
|
|
|
|
def test_forbidden_key():
|
|
content = "model: gpt-4\npassword: secret123\n"
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
assert any("password" in e.path for e in errors)
|
|
|
|
|
|
def test_invalid_yaml():
|
|
content = "model: gpt-4\n bad indentation\n"
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
|
|
|
|
def test_nested_validation():
|
|
content = "model: gpt-4\nagent:\n max_turns: not_a_number\n"
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
assert any("max_turns" in e.path for e in errors)
|
|
|
|
|
|
def test_toolsets_validation():
|
|
content = "model: gpt-4\ntoolsets:\n - web\n - 123\n"
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
|
|
|
|
def test_empty_file():
|
|
content = ""
|
|
valid, errors = validate_config(content)
|
|
assert not valid
|
|
|
|
|
|
if __name__ == "__main__":
|
|
tests = [test_valid_config, test_missing_required_key, test_wrong_type,
|
|
test_forbidden_key, test_invalid_yaml, test_nested_validation,
|
|
test_toolsets_validation, test_empty_file]
|
|
for t in tests:
|
|
print(f"Running {t.__name__}...")
|
|
t()
|
|
print(" PASS")
|
|
print("\nAll tests passed.")
|