Commit ea042771 authored by Paris Stentoumis's avatar Paris Stentoumis
Browse files

fix: aligned service order type with specs and added tests for enum values

parent aa046126
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -13,13 +13,11 @@ class ServiceOrderType(StrEnum):
    DEPLOY_SERVICE = "deploy_service"
    SCALE_SERVICE = "scale_service"
    TERMINATE_SERVICE = "terminate_service"
    UPDATE_SERVICE = "update_service"

    ACTIVATE_CAPABILITY = "activate_capability"
    UPDATE_CAPABILITY = "update_capability"
    TERMINATE_CAPABILITY = "terminate_capability"
    DEACTIVATE_CAPABILITY = "deactivate_capability"

    QUERY_CAPABILITY = "query_capability"
    RECONCILE_SERVICE = "reconcile_service"


+34 −1
Original line number Diff line number Diff line
"""Round-trip coverage for every SQL repository against real PostgreSQL.

The core contract of every repository is the same: ``save()`` persists an entity,
The core contract of every repository is the same: ``create()`` persists an entity,
assigns a surrogate id, and ``get_by_id()`` returns an equal aggregate. This is
asserted uniformly across all repositories so each one has baseline coverage.
"""
@@ -224,6 +224,12 @@ def _service_order(zone_id: UUID) -> ServiceOrder:
    )


def _service_order_with_type(zone_id: UUID, order_type: ServiceOrderType) -> ServiceOrder:
    order = _service_order(zone_id)
    order.order_type = order_type
    return order


def _capability_instance(
    service_instance_id: UUID, capability_id: UUID, originating_service_order_id: UUID
) -> CapabilityInstance:
@@ -395,6 +401,33 @@ async def test_create_assigns_id_and_get_by_id_round_trips(
    assert reloaded == saved


def test_service_order_type_values_match_persistence_model() -> None:
    assert {order_type.value for order_type in ServiceOrderType} == {
        "deploy_service",
        "scale_service",
        "terminate_service",
        "activate_capability",
        "update_capability",
        "deactivate_capability",
        "reconcile_service",
    }


async def test_service_order_create_accepts_deactivate_capability(
    db_session: AsyncSession,
) -> None:
    zone = await SqlZoneRepository(db_session).create(_zone())
    repo = SqlServiceOrderRepository(db_session)
    saved = await repo.create(
        _service_order_with_type(zone.id, ServiceOrderType.DEACTIVATE_CAPABILITY)
    )

    reloaded = await repo.get_by_id(saved.id)

    assert reloaded is not None
    assert reloaded.order_type == ServiceOrderType.DEACTIVATE_CAPABILITY


class TestChildRepositoriesGetById:
    """Deployment units and capability requirements are written via the aggregate
    root, so only their get_by_id is exercised directly."""