Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /dislovelhl_enhanced-agent-bus /tests /constitutional_saga /testsagacompensation.py
| """ | |
| Comprehensive tests for Constitutional Saga workflow module. | |
| Constitutional Hash: 608508a9bd224290 | |
| Coverage targets: | |
| - SagaStatus and StepStatus enums | |
| - SagaCompensation, SagaStep, SagaContext, SagaResult, SagaState dataclasses | |
| - FileSagaPersistenceProvider | |
| - DefaultSagaActivities | |
| - Saga execution and compensation flow | |
| """ | |
| import asyncio | |
| import json | |
| import tempfile | |
| from datetime import datetime, timezone | |
| from pathlib import Path | |
| from unittest.mock import AsyncMock, MagicMock | |
| import pytest | |
| from enhanced_agent_bus.deliberation_layer.workflows.constitutional_saga import ( | |
| CONSTITUTIONAL_HASH, | |
| DefaultSagaActivities, | |
| FileSagaPersistenceProvider, | |
| SagaCompensation, | |
| SagaContext, | |
| SagaResult, | |
| SagaState, | |
| SagaStatus, | |
| SagaStep, | |
| StepStatus, | |
| ) | |
| class TestSagaCompensation: | |
| """Tests for SagaCompensation dataclass.""" | |
| def sample_compensation(self): | |
| """Create sample compensation.""" | |
| async def execute_fn(ctx): | |
| return True | |
| return SagaCompensation( | |
| name="test_compensation", | |
| execute=execute_fn, | |
| description="Test compensation action", | |
| idempotency_key="test-key-123", | |
| max_retries=5, | |
| retry_delay_seconds=2.0, | |
| ) | |
| def test_basic_creation(self, sample_compensation): | |
| """Test basic compensation creation.""" | |
| assert sample_compensation.name == "test_compensation" | |
| assert sample_compensation.description == "Test compensation action" | |
| def test_default_values(self): | |
| """Test default values.""" | |
| async def execute_fn(ctx): | |
| return True | |
| comp = SagaCompensation(name="minimal", execute=execute_fn) | |
| assert comp.description == "" | |
| assert comp.idempotency_key is None | |
| assert comp.max_retries == 3 | |
| assert comp.retry_delay_seconds == 1.0 | |
| def test_custom_retry_settings(self, sample_compensation): | |
| """Test custom retry settings.""" | |
| assert sample_compensation.max_retries == 5 | |
| assert sample_compensation.retry_delay_seconds == 2.0 | |
Xet Storage Details
- Size:
- 2.13 kB
- Xet hash:
- 4c2242a69871b7299b332be4296260a4fb1eb412274e670b239569fca73b11db
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.