File size: 2,091 Bytes
e65c395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Pytest configuration and fixtures."""

import pytest
from unittest.mock import AsyncMock, MagicMock


@pytest.fixture
def sample_queries():
    """Sample queries for testing."""
    return {
        "simple": [
            "Hello",
            "What is 2 + 2?",
            "What is the capital of France?",
            "Hi there",
            "Thanks!",
        ],
        "medium": [
            "Explain the difference between TCP and UDP.",
            "What are the main features of Python 3.11?",
            "How does garbage collection work in Java?",
            "Describe the MVC architecture pattern.",
        ],
        "complex": [
            "Write a Python function that implements a binary search tree.",
            "Create a REST API with authentication using FastAPI.",
            "Implement a neural network from scratch in Python.",
            "Design a distributed caching system with Redis.",
            "Write a compiler for a simple programming language.",
        ],
    }


@pytest.fixture
def mock_openai_response():
    """Mock OpenAI API response."""
    return {
        "id": "chatcmpl-123",
        "object": "chat.completion",
        "created": 1234567890,
        "model": "gpt-4o",
        "choices": [
            {
                "index": 0,
                "message": {
                    "role": "assistant",
                    "content": "This is a test response.",
                },
                "finish_reason": "stop",
            }
        ],
        "usage": {
            "prompt_tokens": 10,
            "completion_tokens": 20,
            "total_tokens": 30,
        },
    }


@pytest.fixture
def mock_redis_client():
    """Mock Redis client."""
    client = AsyncMock()
    client.get.return_value = None
    client.setex.return_value = True
    client.delete.return_value = 1
    client.ping.return_value = True
    return client


@pytest.fixture
def mock_qdrant_client():
    """Mock Qdrant client."""
    client = MagicMock()
    client.search.return_value = []
    client.upsert.return_value = None
    return client