mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-02 02:58:10 +02:00
Squashed 'ai-context/trustgraph-templates/' content from commit 42a5fd1b
git-subtree-dir: ai-context/trustgraph-templates git-subtree-split: 42a5fd1b678f32be378062e30451e2052ccb95dd
This commit is contained in:
commit
74cc8a4685
1216 changed files with 116347 additions and 0 deletions
83
tests/validation/test_semantics_tg.py
Normal file
83
tests/validation/test_semantics_tg.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
"""
|
||||
Semantic validation tests for TrustGraph configuration.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add parent directory to path for validators import
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
from validators import trustgraph
|
||||
|
||||
|
||||
@pytest.mark.validation
|
||||
@pytest.mark.parametrize("config", ["minimal.json", "complex-rag.json", "multi-service.json"])
|
||||
def test_tg_config_semantic_validation(config, run_configurator, test_config_dir, primary_version):
|
||||
"""Test semantic validation of TrustGraph configuration."""
|
||||
config_file = str(test_config_dir / config)
|
||||
|
||||
stdout, stderr, code = run_configurator([
|
||||
'-t', primary_version,
|
||||
'-p', 'docker-compose',
|
||||
'-i', config_file,
|
||||
'--latest-stable',
|
||||
'-O'
|
||||
])
|
||||
|
||||
assert code == 0
|
||||
|
||||
is_valid, errors = trustgraph.validate_trustgraph_config(stdout)
|
||||
|
||||
if not is_valid:
|
||||
error_msg = "\n".join(errors)
|
||||
# Some errors might be warnings, so we log them but don't necessarily fail
|
||||
# Adjust this based on strictness requirements
|
||||
if any("missing" in err.lower() or "required" in err.lower() for err in errors):
|
||||
pytest.fail(f"Semantic validation failed for {config}:\n{error_msg}")
|
||||
|
||||
|
||||
@pytest.mark.validation
|
||||
def test_tg_config_has_llm(run_configurator, test_config_dir, primary_version):
|
||||
"""Test that TrustGraph config includes LLM provider."""
|
||||
config_file = str(test_config_dir / "minimal.json")
|
||||
|
||||
stdout, stderr, code = run_configurator([
|
||||
'-t', primary_version,
|
||||
'-p', 'docker-compose',
|
||||
'-i', config_file,
|
||||
'--latest-stable',
|
||||
'-O'
|
||||
])
|
||||
|
||||
assert code == 0
|
||||
|
||||
tg_config = trustgraph.parse_trustgraph_config(stdout)
|
||||
errors = trustgraph.validate_llm_configuration(tg_config)
|
||||
|
||||
# LLM should be configured
|
||||
if errors:
|
||||
# This might be a warning rather than error for some configs
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.validation
|
||||
def test_tg_config_structure(run_configurator, test_config_dir, primary_version):
|
||||
"""Test that TrustGraph config has required structure."""
|
||||
config_file = str(test_config_dir / "minimal.json")
|
||||
|
||||
stdout, stderr, code = run_configurator([
|
||||
'-t', primary_version,
|
||||
'-p', 'docker-compose',
|
||||
'-i', config_file,
|
||||
'--latest-stable',
|
||||
'-O'
|
||||
])
|
||||
|
||||
assert code == 0
|
||||
|
||||
tg_config = trustgraph.parse_trustgraph_config(stdout)
|
||||
errors = trustgraph.validate_required_structure(tg_config)
|
||||
|
||||
if errors:
|
||||
pytest.fail(f"Invalid TrustGraph config structure:\n" + "\n".join(errors))
|
||||
Loading…
Add table
Add a link
Reference in a new issue