Spaces:
Runtime error
Runtime error
| # tests/test_analyzer.py | |
| import pytest | |
| from modules.analyzer import Analyzer | |
| def test_analyzer_init(): | |
| analyzer = Analyzer(base_url="https://test.api", api_key="test_key") | |
| assert analyzer.client.base_url == "https://test.api/" | |
| assert analyzer.client.api_key == "test_key" | |
| def test_analyzer_analyze(monkeypatch): | |
| # Mock the OpenAI client response | |
| class MockChoice: | |
| def __init__(self): | |
| self.message = MockMessage() | |
| class MockMessage: | |
| def __init__(self): | |
| self.content = "Test analysis result" | |
| class MockResponse: | |
| def __init__(self): | |
| self.choices = [MockChoice()] | |
| class MockClient: | |
| def chat.completions.create(self, *args, **kwargs): | |
| return MockResponse() | |
| def mock_openai_init(*args, **kwargs): | |
| return MockClient() | |
| monkeypatch.setattr("modules.analyzer.OpenAI", mock_openai_init) | |
| analyzer = Analyzer(base_url="https://test.api", api_key="test_key") | |
| result = analyzer.analyze("test query", [{"content": "test content"}]) | |
| assert result == "Test analysis result" |