Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
from PIL import Image
from pymilvus import Collection, CollectionSchema, DataType, FieldSchema

from encoder import Base64ImageProcessor
from milvus_utils import (
from .encoder import Base64ImageProcessor
from .milvus_utils import (
CollectionExists,
create_collection,
get_milvus_client,
get_search_results,
)
from schemas import PayloadSchema, TensorSchema
from .schemas import PayloadSchema, TensorSchema

load_dotenv()

Expand Down
136 changes: 136 additions & 0 deletions metro-ai-suite/image-based-video-search/test/QUICK_TEST_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Quick Test Reference Guide

## 🚀 Running Tests

### Setup (First Time Only)
```bash
# Navigate to project directory
cd /edge-ai-suites/metro-ai-suite/image-based-video-search

# Create and activate virtual environment
python3 -m venv ./test-venv

source test-venv/bin/activate
```
### Install Requirements
```bash
pip install -r ./test/requirements.txt
```

### Run All Tests with Coverage
```bash
# Note: You must temporarily modify server.py imports before running tests
# See "Important Notes" section below

# Run all tests with coverage
pytest test/ --cov=src/feature-matching --cov-report=term-missing

# Run all tests with HTML coverage report
pytest test/ --cov=src/feature-matching --cov-report=html
```

### Run Individual Test Files
```bash
pytest test/test_encoder.py -v
pytest test/test_milvus_utils.py -v
pytest test/test_schemas.py -v
pytest test/test_server.py -v
```

### Run Specific Test
```bash
pytest test/test_encoder.py::TestBase64ImageProcessor::test_processor_initialization_default_size -v
```

## 📊 Current Test Results

- **Total Tests:** 92
- **Passing:** 88 (95.7%)
- **Failing:** 4 (4.3%)
- **Overall Coverage:** 95%

### Coverage by Module
- encoder.py: 100%
- milvus_utils.py: 100%
- schemas.py: 100%
- server.py: 92%

## ⚠️ Important Notes

### Temporary Import Modification Required

Before running tests, you need to temporarily modify `src/feature-matching/server.py`:

**Change FROM (relative imports):**
```python
from .encoder import Base64ImageProcessor
from .milvus_utils import (...)
from .schemas import PayloadSchema, TensorSchema
```

**TO (absolute imports):**
```python
from encoder import Base64ImageProcessor
from milvus_utils import (...)
from schemas import PayloadSchema, TensorSchema
```

**Quick command to make this change:**
```bash
cd src/feature-matching
cp server.py server.py.bak # Backup original
sed -i 's/from \.encoder import/from encoder import/g' server.py
sed -i 's/from \.milvus_utils import/from milvus_utils import/g' server.py
sed -i 's/from \.schemas import/from schemas import/g' server.py
```

**Restore after testing:**
```bash
cd src/feature-matching
mv server.py.bak server.py # Restore original
```

### Why This Is Needed
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.

## 📁 Generated Reports

1. **htmlcov/index.html** - Interactive HTML coverage report

### View HTML Report
```bash
# Open in default browser
xdg-open htmlcov/index.html

# Or specify browser
firefox htmlcov/index.html
google-chrome htmlcov/index.html
```

## 🐛 Known Issues

### Test Failures (4 total)

1. ❌ **test_create_collection_new_collection** - Test assertion issue
2. ❌ **test_get_milvus_client_with_different_uris** - Import error in test
3. ❌ **test_get_image_file_exists** - Missing test fixture
4. ❌ **test_on_message_invalid_payload** - Production bug (KeyError in server.py:76)

Only #4 is a real production bug that needs fixing.
Comment thread
sowmiar1 marked this conversation as resolved.
Outdated

## 🔧 Environment

- Python: 3.12.3
- Pytest: 8.4.2
- Virtual Env: test-venv
- Working Directory: `/edge-ai-suites/metro-ai-suite/image-based-video-search`

## 📚 Additional Resources

- **test/requirements.txt** - All test dependencies
- **test/conftest.py** - Pytest configuration


---

**Last Updated:** November 11, 2025
17 changes: 16 additions & 1 deletion metro-ai-suite/image-based-video-search/test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
selenium
python-dotenv
python-dotenv
pytest>=7.4.0,<9.0.0
pytest-cov>=4.1.0,<6.0.0
pytest-asyncio>=0.21.0,<1.0.0
pytest-mock>=3.11.0,<4.0.0
fastapi>=0.104.0,<1.0.0
httpx>=0.25.0,<1.0.0
python-multipart>=0.0.6,<1.0.0
uvicorn>=0.24.0,<1.0.0
marshmallow>=3.20.0,<4.0.0
pydantic>=2.0.0,<3.0.0
Pillow>=10.0.0,<12.0.0
pymilvus>=2.3.0,<3.0.0
paho-mqtt>=1.6.0,<3.0.0
python-dotenv>=1.0.0,<2.0.0
numpy>=1.24.0,<3.0.0
Loading
Loading