Buckets:

download
raw
2.05 kB
"""
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 TestSagaStateEdgeCases:
"""Tests for SagaState edge cases."""
def test_state_with_empty_lists(self):
"""Test state with empty lists."""
state = SagaState(
saga_id="empty-saga",
status=SagaStatus.PENDING,
completed_steps=[],
failed_step=None,
compensated_steps=[],
failed_compensations=[],
context={},
)
json_str = state.to_json()
restored = SagaState.from_json(json_str)
assert restored.completed_steps == []
assert restored.compensated_steps == []
def test_state_with_complex_context(self):
"""Test state with complex nested context."""
complex_context = {"level1": {"level2": {"data": [1, 2, 3], "nested": {"key": "value"}}}}
state = SagaState(
saga_id="complex-saga",
status=SagaStatus.COMPLETED,
completed_steps=["step1"],
failed_step=None,
compensated_steps=[],
failed_compensations=[],
context=complex_context,
)
json_str = state.to_json()
restored = SagaState.from_json(json_str)
assert restored.context["level1"]["level2"]["data"] == [1, 2, 3]

Xet Storage Details

Size:
2.05 kB
·
Xet hash:
5aa129ad69ce849dbb563ad1820b46ebf82c42d082dca328ddacc2c3975e5925

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.