File size: 1,578 Bytes
4dc3b79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pytest
from fastapi.testclient import TestClient
from pathlib import Path
import tempfile

from app.main import app

client = TestClient(app)

def test_health_check():
    """Test health check endpoint"""
    response = client.get("/api/v1/health")
    assert response.status_code == 200
    data = response.json()
    assert "status" in data
    assert "vector_store" in data

def test_info_endpoint():
    """Test info endpoint"""
    response = client.get("/info")
    assert response.status_code == 200
    data = response.json()
    assert "name" in data
    assert "version" in data

def test_query_endpoint():
    """Test query endpoint (empty vector store)"""
    response = client.post("/api/v1/query", json={"question": "test"})
    assert response.status_code == 200
    data = response.json()
    assert "answer" in data
    assert "sources" in data

def test_search_endpoint():
    """Test search endpoint"""
    response = client.post("/api/v1/search", json={"query": "test"})
    assert response.status_code == 200
    data = response.json()
    assert "results" in data
    assert "total_results" in data

def test_collection_stats():
    """Test collection stats endpoint"""
    response = client.get("/api/v1/collection/stats")
    assert response.status_code == 200
    data = response.json()
    assert "total_documents" in data

# Note: Upload tests would require actual files
# Note: TFS sync tests would require TFS configuration

if __name__ == "__main__":
    pytest.main([__file__, "-v"])