ayushm98 commited on
Commit
e65c395
·
1 Parent(s): e6f8f7b

Add pytest configuration and test fixtures

Browse files
Files changed (2) hide show
  1. tests/__init__.py +1 -0
  2. tests/conftest.py +77 -0
tests/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Tests for Cascade."""
tests/conftest.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pytest configuration and fixtures."""
2
+
3
+ import pytest
4
+ from unittest.mock import AsyncMock, MagicMock
5
+
6
+
7
+ @pytest.fixture
8
+ def sample_queries():
9
+ """Sample queries for testing."""
10
+ return {
11
+ "simple": [
12
+ "Hello",
13
+ "What is 2 + 2?",
14
+ "What is the capital of France?",
15
+ "Hi there",
16
+ "Thanks!",
17
+ ],
18
+ "medium": [
19
+ "Explain the difference between TCP and UDP.",
20
+ "What are the main features of Python 3.11?",
21
+ "How does garbage collection work in Java?",
22
+ "Describe the MVC architecture pattern.",
23
+ ],
24
+ "complex": [
25
+ "Write a Python function that implements a binary search tree.",
26
+ "Create a REST API with authentication using FastAPI.",
27
+ "Implement a neural network from scratch in Python.",
28
+ "Design a distributed caching system with Redis.",
29
+ "Write a compiler for a simple programming language.",
30
+ ],
31
+ }
32
+
33
+
34
+ @pytest.fixture
35
+ def mock_openai_response():
36
+ """Mock OpenAI API response."""
37
+ return {
38
+ "id": "chatcmpl-123",
39
+ "object": "chat.completion",
40
+ "created": 1234567890,
41
+ "model": "gpt-4o",
42
+ "choices": [
43
+ {
44
+ "index": 0,
45
+ "message": {
46
+ "role": "assistant",
47
+ "content": "This is a test response.",
48
+ },
49
+ "finish_reason": "stop",
50
+ }
51
+ ],
52
+ "usage": {
53
+ "prompt_tokens": 10,
54
+ "completion_tokens": 20,
55
+ "total_tokens": 30,
56
+ },
57
+ }
58
+
59
+
60
+ @pytest.fixture
61
+ def mock_redis_client():
62
+ """Mock Redis client."""
63
+ client = AsyncMock()
64
+ client.get.return_value = None
65
+ client.setex.return_value = True
66
+ client.delete.return_value = 1
67
+ client.ping.return_value = True
68
+ return client
69
+
70
+
71
+ @pytest.fixture
72
+ def mock_qdrant_client():
73
+ """Mock Qdrant client."""
74
+ client = MagicMock()
75
+ client.search.return_value = []
76
+ client.upsert.return_value = None
77
+ return client