H.1.5: Tests for Component Discovery Service
Tests cover:
- Component registration and unregistration
- Capability-based discovery
- Type-based discovery
- Health filtering and load balancing
- Heartbeat mechanism
- Local backend fallback
- Bulk registration from activation status
File: test_discovery_service.py
Classes
TestCapability
Tests for Capability dataclass
TestComponent
Tests for Component dataclass
TestLocalDiscoveryBackend
Tests for LocalDiscoveryBackend
TestDiscoveryService
Tests for DiscoveryService (main interface)
TestBulkRegistration
Tests for bulk registration from activation status
Functions
run_tests()
Run all tests
test_capability_creation()
Test creating a capability
test_capability_to_dict()
Test capability serialization
test_capability_from_dict()
Test capability deserialization
test_component_creation()
Test creating a component
test_component_load_ratio()
Test load ratio calculation
test_component_load_ratio_zero_max()
Test load ratio with zero max concurrency
test_component_to_dict()
Test component serialization
test_component_from_dict()
Test component deserialization
setUp()
Set up test fixtures
test_register_component()
Test registering a component
test_unregister_component()
Test unregistering a component
test_unregister_nonexistent()
Test unregistering non-existent component
test_find_by_capability()
Test finding components by capability
test_find_by_type()
Test finding components by type
Usage
python test_discovery_service.py