"""Tests for grid search optimization."""

import pytest
from src.optimization.grid_search import GridSearchOptimizer


class TestGridSearchOptimizer:
    """Tests for GridSearchOptimizer."""
    
    @pytest.fixture
    def optimizer(self):
        """Create grid search optimizer."""
        return GridSearchOptimizer()
    
    def test_optimize_maximize(self, optimizer):
        """Test optimization with maximize."""
        param_grid = {
            'param1': [1, 2, 3],
            'param2': [10, 20]
        }
        
        def objective(params):
            return params['param1'] * params['param2']
        
        result = optimizer.optimize(param_grid, objective, maximize=True)
        
        assert result['best_params'] is not None
        assert result['best_score'] is not None
        assert result['best_score'] > 0
    
    def test_optimize_minimize(self, optimizer):
        """Test optimization with minimize."""
        param_grid = {
            'param1': [1, 2, 3]
        }
        
        def objective(params):
            return params['param1'] * 10
        
        result = optimizer.optimize(param_grid, objective, maximize=False)
        
        assert result['best_params'] is not None
        assert result['best_score'] is not None

