|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import os |
| 3 | +import requests |
| 4 | +import pytest |
| 5 | +import sys |
| 6 | +import json |
| 7 | + |
| 8 | +# Add parent directory to path |
| 9 | +sys.path.append( |
| 10 | + os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 11 | +) |
| 12 | + |
| 13 | + |
| 14 | +class TestE2E: |
| 15 | + """End-to-end tests for the Ignition RAG system.""" |
| 16 | + |
| 17 | + def test_api_health(self, api_url): |
| 18 | + """Test API health endpoint.""" |
| 19 | + response = requests.get(f"{api_url}/health") |
| 20 | + assert response.status_code == 200 |
| 21 | + data = response.json() |
| 22 | + assert data["status"] == "healthy" |
| 23 | + |
| 24 | + def test_query_endpoint(self, api_url): |
| 25 | + """Test the query endpoint with a basic question.""" |
| 26 | + query_data = { |
| 27 | + "query": "Tell me about the tank system", |
| 28 | + "top_k": 3, |
| 29 | + "filter_type": None, |
| 30 | + "filter_path": None, |
| 31 | + } |
| 32 | + |
| 33 | + response = requests.post(f"{api_url}/query", json=query_data) |
| 34 | + |
| 35 | + assert response.status_code == 200 |
| 36 | + data = response.json() |
| 37 | + assert "results" in data |
| 38 | + assert "total" in data |
| 39 | + assert "mock_used" in data |
| 40 | + assert len(data["results"]) > 0 |
| 41 | + |
| 42 | + # Check first result has the expected structure |
| 43 | + first_result = data["results"][0] |
| 44 | + assert "content" in first_result |
| 45 | + assert "metadata" in first_result |
| 46 | + assert "similarity" in first_result |
| 47 | + |
| 48 | + def test_multi_turn_conversation(self, api_url): |
| 49 | + """Test a multi-turn conversation.""" |
| 50 | + # First query |
| 51 | + query1_data = { |
| 52 | + "query": "What is in the tank view?", |
| 53 | + "top_k": 3, |
| 54 | + "filter_type": "perspective", |
| 55 | + "filter_path": None, |
| 56 | + } |
| 57 | + |
| 58 | + response1 = requests.post(f"{api_url}/query", json=query1_data) |
| 59 | + |
| 60 | + assert response1.status_code == 200 |
| 61 | + data1 = response1.json() |
| 62 | + assert "results" in data1 |
| 63 | + assert "total" in data1 |
| 64 | + |
| 65 | + # Follow-up query |
| 66 | + query2_data = { |
| 67 | + "query": "Tell me more about its components", |
| 68 | + "top_k": 3, |
| 69 | + "filter_type": None, |
| 70 | + "filter_path": None, |
| 71 | + } |
| 72 | + |
| 73 | + response2 = requests.post(f"{api_url}/query", json=query2_data) |
| 74 | + |
| 75 | + assert response2.status_code == 200 |
| 76 | + data2 = response2.json() |
| 77 | + assert "results" in data2 |
| 78 | + assert "total" in data2 |
0 commit comments