File size: 3,471 Bytes
11e1578
394963a
60b6623
394963a
186c8e8
394963a
60b6623
 
 
 
 
 
 
 
 
 
 
 
 
186c8e8
60b6623
 
 
 
 
186c8e8
 
394963a
 
 
 
 
 
 
60b6623
394963a
60b6623
 
394963a
60b6623
 
 
186c8e8
60b6623
 
 
 
 
 
186c8e8
60b6623
186c8e8
60b6623
 
 
 
 
186c8e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60b6623
 
 
 
 
186c8e8
 
 
 
 
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# PromptAid Vision Test Suite

This directory contains comprehensive tests for the PromptAid Vision application, organized into two main categories.

## πŸ§ͺ Test Structure

### πŸ“ **Unit Tests** (`unit_tests/`)
Tests for individual components and functions in isolation:
- **`test_basic.py`** - Basic Python and unittest setup verification
- **`test_schema_validator.py`** - Schema validation service tests
- **`test_image_preprocessor.py`** - Image preprocessing service tests
- **`test_vlm_service.py`** - VLM service manager and stub service tests

### πŸ”— **Integration Tests** (`integration_tests/`)
Tests for component interactions, API endpoints, and workflows:
- **`test_upload_flow.py`** - Complete upload workflow with database and API
- **`test_schema_validation.py`** - Schema validation integration tests
- **`test_admin_endpoints.py`** - Admin authentication and model management
- **`test_explore_page.py`** - Frontend explore page functionality
- **`test_openai_integration.py`** - OpenAI API integration tests
- **`test_config.py`** - Configuration and storage system tests
- **`test_core.py`** - Core application functionality tests
- **`test_crisis_analysis_workflow.py`** - Crisis analysis workflow integration tests
- **`test_admin_management_workflow.py`** - Admin management workflow integration tests
- **`test_data_export_workflow.py`** - Data export workflow integration tests

## πŸš€ Running Tests

### Run All Tests
```bash
cd py_backend
python tests/run_tests.py
```

### Run Specific Test Categories
```bash
# Unit tests only
python tests/unit_tests/run_unit_tests.py

# Integration tests only
python tests/integration_tests/run_integration_tests.py
```

### Run Individual Test Files
```bash
cd py_backend
python tests/unit_tests/test_schema_validator.py
python tests/integration_tests/test_upload_flow.py
```

## πŸ“‹ Test Categories Summary

| Category | Count | Purpose | Location |
|----------|-------|---------|----------|
| **Unit Tests** | 4 | Test individual components | `unit_tests/` |
| **Integration Tests** | 10 | Test component interactions and workflows | `integration_tests/` |
| **Total** | **14** | Comprehensive test coverage | `tests/` |

## πŸ”§ Test Environment

- **Backend**: FastAPI application with PostgreSQL database
- **Frontend**: React application with IFRC UI components
- **APIs**: OpenAI, HuggingFace, and custom VLM services
- **Validation**: JSON schema validation for crisis maps and drone images

## πŸ“Š Test Results

Tests provide detailed output including:
- βœ… Success indicators for passed tests
- ❌ Error details for failed tests
- πŸ“‹ Metadata about test execution
- ⏱️ Performance timing information
- πŸ” Detailed validation results

## 🚨 Troubleshooting

### Common Issues
1. **Import Errors**: Ensure you're running from the `py_backend` directory
2. **Database Connection**: Verify PostgreSQL is running and accessible
3. **API Keys**: Check environment variables for required API keys
4. **Backend Status**: Ensure FastAPI backend is running on expected port

### Test Configuration
- Set `ADMIN_PASSWORD` environment variable for admin endpoint tests
- Ensure backend is running on `localhost:8000` for integration tests
- Update `BASE_URL` in test files if using different backend URL

### Getting Help
- Check test output for specific error messages
- Verify environment configuration
- Ensure all dependencies are installed
- Check backend logs for additional context