"""
Real environment tests for IFlow API.
Requires IFLOW_API_KEY environment variable.
"""

import os
import pytest
from oiiai import FetchIFlow


class TestIFlowReal:
    """Real environment tests for IFlow API."""
    
    @pytest.fixture
    def api_key(self):
        """Get API key from environment."""
        key = os.getenv("IFLOW_API_KEY")
        if not key:
            pytest.skip("IFLOW_API_KEY environment variable not set")
        return key
    
    @pytest.fixture
    def fetcher(self):
        """Create fetcher instance."""
        return FetchIFlow()
    
    def test_fetch_models_real(self, fetcher):
        """Test fetching models from IFlow API."""
        models = fetcher.fetch_models()
        
        # Basic validation
        assert isinstance(models, list)
        assert len(models) > 0
        
        # Check model format
        for model in models:
            assert isinstance(model, str)
            assert len(model) > 0
        
        # Log results
        print(f"IFlow: Found {len(models)} models")
        print(f"Sample models: {models[:5]}")
    
    def test_fetch_models_with_timeout(self, fetcher):
        """Test fetching models with timeout."""
        models = fetcher.fetch_models(timeout=30)
        
        assert isinstance(models, list)
        assert len(models) > 0