|
| 1 | +# Quick Test Reference Guide |
| 2 | + |
| 3 | +## 🚀 Running Tests |
| 4 | + |
| 5 | +### Setup (First Time Only) |
| 6 | +```bash |
| 7 | +# Navigate to project directory |
| 8 | +cd /edge-ai-suites/metro-ai-suite/image-based-video-search |
| 9 | + |
| 10 | +# Create and activate virtual environment |
| 11 | +python3 -m venv ./test-venv |
| 12 | + |
| 13 | +source test-venv/bin/activate |
| 14 | +``` |
| 15 | +### Install Requirements |
| 16 | +```bash |
| 17 | +pip install -r ./test/requirements.txt |
| 18 | +``` |
| 19 | + |
| 20 | +### Run All Tests with Coverage |
| 21 | +```bash |
| 22 | +# Note: You must temporarily modify server.py imports before running tests |
| 23 | +# See "Important Notes" section below |
| 24 | + |
| 25 | +# Run all tests with coverage |
| 26 | +pytest test/ --cov=src/feature-matching --cov-report=term-missing |
| 27 | + |
| 28 | +# Run all tests with HTML coverage report |
| 29 | +pytest test/ --cov=src/feature-matching --cov-report=html |
| 30 | +``` |
| 31 | + |
| 32 | +### Run Individual Test Files |
| 33 | +```bash |
| 34 | +pytest test/test_encoder.py -v |
| 35 | +pytest test/test_milvus_utils.py -v |
| 36 | +pytest test/test_schemas.py -v |
| 37 | +pytest test/test_server.py -v |
| 38 | +``` |
| 39 | + |
| 40 | +### Run Specific Test |
| 41 | +```bash |
| 42 | +pytest test/test_encoder.py::TestBase64ImageProcessor::test_processor_initialization_default_size -v |
| 43 | +``` |
| 44 | + |
| 45 | +## 📊 Current Test Results |
| 46 | + |
| 47 | +- **Total Tests:** 92 |
| 48 | +- **Passing:** 88 (95.7%) |
| 49 | +- **Failing:** 4 (4.3%) |
| 50 | +- **Overall Coverage:** 95% |
| 51 | + |
| 52 | +### Coverage by Module |
| 53 | +- encoder.py: 100% |
| 54 | +- milvus_utils.py: 100% |
| 55 | +- schemas.py: 100% |
| 56 | +- server.py: 92% |
| 57 | + |
| 58 | +## ⚠️ Important Notes |
| 59 | + |
| 60 | +### Temporary Import Modification Required |
| 61 | + |
| 62 | +Before running tests, you need to temporarily modify `src/feature-matching/server.py`: |
| 63 | + |
| 64 | +**Change FROM (relative imports):** |
| 65 | +```python |
| 66 | +from .encoder import Base64ImageProcessor |
| 67 | +from .milvus_utils import (...) |
| 68 | +from .schemas import PayloadSchema, TensorSchema |
| 69 | +``` |
| 70 | + |
| 71 | +**TO (absolute imports):** |
| 72 | +```python |
| 73 | +from encoder import Base64ImageProcessor |
| 74 | +from milvus_utils import (...) |
| 75 | +from schemas import PayloadSchema, TensorSchema |
| 76 | +``` |
| 77 | + |
| 78 | +**Quick command to make this change:** |
| 79 | +```bash |
| 80 | +cd src/feature-matching |
| 81 | +cp server.py server.py.bak # Backup original |
| 82 | +sed -i 's/from \.encoder import/from encoder import/g' server.py |
| 83 | +sed -i 's/from \.milvus_utils import/from milvus_utils import/g' server.py |
| 84 | +sed -i 's/from \.schemas import/from schemas import/g' server.py |
| 85 | +``` |
| 86 | + |
| 87 | +**Restore after testing:** |
| 88 | +```bash |
| 89 | +cd src/feature-matching |
| 90 | +mv server.py.bak server.py # Restore original |
| 91 | +``` |
| 92 | + |
| 93 | +### Why This Is Needed |
| 94 | +The `src/feature-matching` directory uses hyphens (not valid in Python module names), so the tests add it to `sys.path` and import directly. The relative imports in `server.py` won't work in this configuration, so we temporarily convert them to absolute imports. |
| 95 | + |
| 96 | +## 📁 Generated Reports |
| 97 | + |
| 98 | +1. **htmlcov/index.html** - Interactive HTML coverage report |
| 99 | + |
| 100 | +### View HTML Report |
| 101 | +```bash |
| 102 | +# Open in default browser |
| 103 | +xdg-open htmlcov/index.html |
| 104 | + |
| 105 | +# Or specify browser |
| 106 | +firefox htmlcov/index.html |
| 107 | +google-chrome htmlcov/index.html |
| 108 | +``` |
| 109 | + |
| 110 | +## 🔧 Environment |
| 111 | + |
| 112 | +- Python: 3.12.3 |
| 113 | +- Pytest: 8.4.2 |
| 114 | +- Virtual Env: test-venv |
| 115 | +- Working Directory: `/edge-ai-suites/metro-ai-suite/image-based-video-search` |
| 116 | + |
| 117 | +## 📚 Additional Resources |
| 118 | + |
| 119 | +- **test/requirements.txt** - All test dependencies |
| 120 | +- **test/conftest.py** - Pytest configuration |
| 121 | + |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +**Last Updated:** November 11, 2025 |
0 commit comments