Comprehensive web-based event management and conference lifecycle management platform.
—
Indico provides comprehensive testing infrastructure including pytest integration, extensive fixture systems, and utilities for creating parameterized tests. The testing framework supports both core development and plugin testing with realistic data and proper application context.
Indico includes a pytest plugin that automatically configures the testing environment and provides access to all testing fixtures.
# Pytest plugin is automatically registered via entry point
# No explicit import needed - fixtures are available when using pytestConfiguration in pyproject.toml:
[project.entry-points."pytest11"]
indico = "indico.testing.pytest_plugin"Core testing utility functions for creating parameterized tests and handling test data.
def bool_matrix(template, mask, expect):
"""
Create boolean matrix for parameterized tests.
Generates test parameter combinations based on a template with boolean
placeholders, applying a mask to filter combinations, and mapping results
to expected outcomes.
Parameters:
- template: str or callable, test parameter template
- mask: dict, mask to apply to boolean combinations
- expect: dict, expected results for each combination
Returns:
list: List of pytest parameter tuples for @pytest.mark.parametrize
"""Usage example:
import pytest
from indico.testing.util import bool_matrix
# Create parameterized test cases
test_cases = bool_matrix(
template="user={user_exists}, admin={is_admin}",
mask={'user_exists': True, 'is_admin': [True, False]},
expect={
(True, True): 'admin_access',
(True, False): 'user_access'
}
)
@pytest.mark.parametrize("params,expected", test_cases)
def test_access_control(params, expected):
# Test implementation
passEssential fixtures for application testing and database operations.
# Available automatically when using Indico's pytest plugin
def app():
"""Flask application instance with test configuration."""
def request_context():
"""Flask request context for testing."""
def db():
"""Database session for testing."""def dummy_user():
"""Create a test user instance."""
def create_user():
"""Factory function for creating test users."""
def dummy_admin():
"""Create a test admin user."""def dummy_event():
"""Create a test event instance."""
def create_event():
"""Factory function for creating test events."""
def dummy_category():
"""Create a test category."""
def create_category():
"""Factory function for creating test categories."""def dummy_contribution():
"""Create a test contribution."""
def create_contribution():
"""Factory function for creating test contributions."""
def dummy_session():
"""Create a test session."""
def create_session():
"""Factory function for creating test sessions."""def dummy_room():
"""Create a test room."""
def create_room():
"""Factory function for creating test rooms."""
def dummy_reservation():
"""Create a test room reservation."""
def create_reservation():
"""Factory function for creating reservations."""def dummy_abstract():
"""Create a test abstract submission."""
def create_abstract():
"""Factory function for creating test abstracts."""Fixtures for testing caching functionality and cache-dependent features.
def redis_proc():
"""Redis process fixture for cache testing."""
def redis():
"""Redis client fixture."""def test_user_creation(create_user, db):
"""Test user creation with fixtures."""
user = create_user(email='test@example.com', first_name='Test')
db.session.add(user)
db.session.commit()
assert user.email == 'test@example.com'
assert user.first_name == 'Test'
def test_event_management(dummy_event, dummy_user):
"""Test event management functionality."""
event = dummy_event
user = dummy_user
# Test event operations
assert event.title
assert event.creator == user@pytest.mark.parametrize("user_type,access_level", [
('admin', 'full'),
('manager', 'limited'),
('user', 'read_only')
])
def test_access_levels(user_type, access_level, create_user):
"""Test different user access levels."""
user = create_user(user_type=user_type)
# Test access level logic
passdef test_plugin_functionality(app, dummy_event):
"""Test plugin functionality."""
from my_plugin import MyPlugin
plugin = MyPlugin(app.extensions['indico_plugins'])
plugin.init()
# Test plugin behavior
result = plugin.process_event(dummy_event)
assert result is not NoneUtilities for testing email functionality in events and notifications.
# Email testing utilities are available in indico.testing.util
# Specific functions for email validation and testingYAML and JSON processing helpers for test data management.
# YAML and JSON processing utilities available in indico.testing.util
# Functions for loading and processing test data filesThe pytest plugin automatically configures:
# Run all tests
pytest
# Run specific test file
pytest tests/core/test_plugins.py
# Run tests with coverage
pytest --cov=indico
# Run tests for specific plugin
pytest tests/plugins/test_my_plugin.pyInstall with Tessl CLI
npx tessl i tessl/pypi-indico