This directory contains comprehensive integration tests for all NexusAI services.
Integration tests verify that services work together correctly in a real-world scenario. Unlike unit tests that test individual components in isolation, integration tests ensure:
- Services can communicate with each other
- Database operations work correctly
- External API integrations function properly
- Error handling works across service boundaries
- Performance meets requirements
Tests for the Image Generation service:
- ✅ Full image generation workflow
- ✅ Different models (imagen-3.0-generate-001, imagen-3.0-fast-generate-001)
- ✅ Different aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)
- ✅ Safety filter levels
- ✅ Error handling (missing/empty prompts)
- ✅ Concurrent requests
- ✅ Database integration
- ✅ Performance testing
Tests for the Chat service:
- ✅ Simple chat interactions
- ✅ Conversation history management
- ✅ Tool integration (Google Search, Code Execution)
- ✅ Multiple tools simultaneously
- ✅ Different Gemini models
- ✅ Response cleaning (triple quotes removal)
- ✅ Database integration
- ✅ Error handling (empty messages, invalid history)
- ✅ Concurrent chat sessions
- ✅ Long conversation histories
- ✅ Performance testing
Tests for the Director service (Video Creation):
- ✅ New movie job creation
- ✅ Movie creation with existing scenes (retake/edit flow)
- ✅ Script generation workflow
- ✅ Script approval process
- ✅ Movie status tracking
- ✅ User jobs retrieval
- ✅ External job saving (from TextToVideo)
- ✅ Database integration
- ✅ Authorization checks
- ✅ Concurrent movie creation
- ✅ Performance testing
Tests for the Video Generation service:
- ✅ Text-to-video workflow
- ✅ Image-to-video workflow
- ✅ Video extension workflow
- ✅ Status polling
- ✅ Save local workflow
- ✅ Different models (veo-3.1, veo-3.1-fast-generate-preview)
- ✅ Different durations (4s, 8s)
- ✅ Different resolutions (720p, 1080p)
- ✅ Different aspect ratios (16:9, 9:16, 1:1)
- ✅ Error handling (missing prompt, invalid duration, invalid operation)
- ✅ Concurrent requests
- ✅ Performance testing
Tests for the Document Summarization service:
- ✅ Text summarization workflow
- ✅ PDF document summarization
- ✅ DOCX document summarization
- ✅ TXT file summarization
- ✅ Different Gemini models
- ✅ Very long documents
- ✅ Short documents
- ✅ Error handling (empty text, unsupported files, corrupted files)
- ✅ Database integration
- ✅ Concurrent requests
- ✅ Performance testing
- ✅ Summary quality checks
Tests for the YouTube Transcript service:
- ✅ Transcript extraction workflow
- ✅ Transcript summarization
- ✅ Different YouTube URL formats
- ✅ Language-specific transcripts
- ✅ Transcripts with timestamps
- ✅ Error handling (invalid URL, video not found, no transcript, language unavailable)
- ✅ Database integration
- ✅ Long video transcripts
- ✅ Concurrent requests
- ✅ Performance testing
- ✅ Transcript formatting
Tests for deployed environment:
- ✅ Gateway health checks
- ✅ Backend services health (via Nginx routing)
- ✅ Real API end-to-end tests (optional, requires API keys)
- ✅ Request validation and security
- ✅ CORS headers
pytest tests/integration -vpytest tests/integration/test_image_generation_integration.py -v
pytest tests/integration/test_chat_integration.py -v
pytest tests/integration/test_director_integration.py -v
pytest tests/integration/test_video_generation_integration.py -v
pytest tests/integration/test_document_summarization_integration.py -v
pytest tests/integration/test_youtube_transcript_integration.py -v
pytest tests/integration/test_integration_deployment.py -vpytest tests/integration/test_image_generation_integration.py::TestImageGenerationIntegration -vpytest tests/integration/test_chat_integration.py::TestChatIntegration::test_simple_chat_workflow -vpytest tests/integration --cov=. --cov-report=htmlpytest tests/integration -vv --tb=long- Python 3.8+
- All dependencies installed:
pip install .(usespyproject.toml) - No API keys required (tests use mocks)
- Set environment variables:
export GEMINI_API_KEY=your_key_here export GOOGLE_CLOUD_PROJECT=your_project_id
- Services running (for deployment tests):
docker-compose up # OR ./start_all.ps1
Each integration test follows this pattern:
class TestServiceIntegration:
def test_health_endpoint(self):
"""Verify service is running"""
def test_main_workflow(self, mock_api):
"""Test the primary use case"""
def test_edge_cases(self):
"""Test boundary conditions"""
def test_error_handling(self):
"""Test failure scenarios"""
def test_database_integration(self):
"""Verify database operations"""
def test_performance(self):
"""Ensure acceptable response times"""Integration tests use mocks for external APIs to:
- ✅ Avoid API costs during testing
- ✅ Ensure consistent test results
- ✅ Test error scenarios that are hard to reproduce
- ✅ Speed up test execution
Mocked components:
- Gemini API (
genai) - Imagen API (
imagen) - Veo API (
client) - YouTube Transcript API (
YouTubeTranscriptApi) - Database (
db) - Storage (
storage)
To integrate these tests into your CI/CD pipeline:
steps:
- name: 'python:3.11'
entrypoint: 'bash'
args:
- '-c'
- |
pip install .
pytest tests/integration -v --tb=short- name: Run Integration Tests
run: |
pip install .
pytest tests/integration -v- Isolation: Each test should be independent and not rely on other tests
- Cleanup: Use fixtures to clean up test data after tests
- Mocking: Mock external APIs to avoid costs and ensure reliability
- Assertions: Use clear, specific assertions with helpful error messages
- Documentation: Document what each test is verifying
- Performance: Set reasonable timeout expectations
- Error Cases: Test both success and failure scenarios
- Ensure services are running:
docker-compose upor./start_all.ps1 - Check port availability (8080, 8001-8006)
- Install dependencies:
pip install .(oruv syncif using uv) - Ensure you're in the project root directory
- For mocked tests: This shouldn't happen (check fixtures)
- For real API tests: Set
GEMINI_API_KEYenvironment variable
- Use mocked tests for development
- Run specific test files instead of all tests
- Use
-kflag to run specific tests:pytest -k "test_simple"
When adding new features:
- Add corresponding integration tests
- Follow the existing test structure
- Use appropriate mocks for external APIs
- Document what the test verifies
- Ensure tests pass before submitting PR
- Unit Tests: 80%+ code coverage
- Integration Tests: Cover all major workflows
- E2E Tests: Cover critical user journeys
- ✅ Run all integration tests:
pytest tests/integration -v - ✅ Check coverage:
pytest tests/integration --cov=. --cov-report=html - ✅ Add to CI/CD pipeline
- ✅ Monitor test execution times
- ✅ Add more edge case tests as needed
For questions or issues with integration tests, please open an issue or contact the development team.