File size: 2,837 Bytes
3f6526a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | #!/usr/bin/env python3
"""
Basic integration test for EV2 Service in ShinkaEvolve.
This script tests the configuration integration without running a full evolution.
"""
import sys
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from shinka.core import EvolutionConfig
def test_config_backward_compatibility():
"""Test that default config doesn't enable eval service."""
print("Test 1: Backward compatibility (default config)...")
config = EvolutionConfig()
assert config.eval_service_url is None, "Default should be None"
print(" ✅ Default config: eval_service_url=None")
def test_config_with_service():
"""Test that eval service can be enabled."""
print("\nTest 2: Enable eval service...")
config = EvolutionConfig(
eval_service_url="http://localhost:8765"
)
assert config.eval_service_url == "http://localhost:8765"
print(" ✅ Config with service: eval_service_url='http://localhost:8765'")
def test_config_from_kwargs():
"""Test that eval service can be set via kwargs."""
print("\nTest 3: Set via kwargs...")
kwargs = {
"num_generations": 10,
"max_parallel_jobs": 2,
"eval_service_url": "http://192.168.1.100:8000",
}
config = EvolutionConfig(**kwargs)
assert config.num_generations == 10
assert config.max_parallel_jobs == 2
assert config.eval_service_url == "http://192.168.1.100:8000"
print(" ✅ Kwargs config works correctly")
def test_notify_method_exists():
"""Test that _notify_eval_service method exists in EvolutionRunner."""
print("\nTest 4: _notify_eval_service method exists...")
from shinka.core import EvolutionRunner
# Check that the method exists
assert hasattr(EvolutionRunner, '_notify_eval_service')
# Check method signature
import inspect
sig = inspect.signature(EvolutionRunner._notify_eval_service)
params = list(sig.parameters.keys())
assert 'self' in params
assert 'generation' in params
assert 'combined_score' in params
assert 'results_dir' in params
print(" ✅ _notify_eval_service method exists")
print(f" - Parameters: {params}")
if __name__ == "__main__":
print("=" * 60)
print("EV2 Service Integration - Basic Tests")
print("=" * 60)
try:
test_config_backward_compatibility()
test_config_with_service()
test_config_from_kwargs()
test_notify_method_exists()
print("\n" + "=" * 60)
print("✅ All basic integration tests passed!")
print("=" * 60)
except Exception as e:
print("\n" + "=" * 60)
print(f"❌ Test failed: {e}")
print("=" * 60)
sys.exit(1)
|