Loading tests/unit/fakes.py +30 −0 Changes for tests/unit/fakes.py: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ from srm.adapters.errors import DuplicateEntryError, DuplicateServiceSpecificati from srm.domain.models.canonical_parameters.result import Result, ResultStatus from srm.domain.models.catalog import RuntimeKind, ServiceSpecification from srm.domain.models.runtime_inventory import CapabilityInstanceState, ServiceInstance from srm.domain.models.runtime_inventory.enums import ServiceInstanceState from srm.domain.models.topology import ( CapabilityKind, CapabilityState, Loading Loading @@ -82,6 +83,13 @@ class InMemoryZoneRepository(ZoneRepository): found = self.rows.get(id) return found.model_copy(deep=True) if found is not None else None async def list_active_resource_zones(self) -> list[Zone]: return [ zone.model_copy(deep=True) for zone in self.rows.values() if zone.kind == ZoneKind.RESOURCE and zone.state == ZoneState.ACTIVE ] async def create(self, zone: Zone) -> Zone: if zone.id in self.rows: raise DuplicateEntryError() Loading @@ -98,6 +106,16 @@ class InMemoryServiceInstanceRepository(ServiceInstanceRepository): found = self.rows.get(id) return found.model_copy(deep=True) if found is not None else None async def list_by_originating_service_order_id( self, originating_service_order_id: UUID, ) -> list[ServiceInstance]: return [ row.model_copy(deep=True) for row in self.rows.values() if row.originating_service_order_id == originating_service_order_id ] async def create(self, service_instance: ServiceInstance) -> ServiceInstance: if service_instance.id in self.rows: raise DuplicateServiceInstanceError() Loading @@ -117,6 +135,18 @@ class InMemoryServiceInstanceRepository(ServiceInstanceRepository): self.rows[stored.id] = stored return stored.model_copy(deep=True) async def update_state( self, id: UUID, state: ServiceInstanceState, ) -> ServiceInstance: found = self.rows.get(id) if found is None: raise KeyError(id) updated = found.model_copy(update={"state": state}, deep=True) self.rows[id] = updated return updated.model_copy(deep=True) class FakeTransformationFunctionAdapter(TransformationFunctionExecutionPort): def get_zones(self, kind: ZoneKind | None = None) -> list[TransformationFunctionZone]: Loading Loading
tests/unit/fakes.py +30 −0 Changes for tests/unit/fakes.py: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ from srm.adapters.errors import DuplicateEntryError, DuplicateServiceSpecificati from srm.domain.models.canonical_parameters.result import Result, ResultStatus from srm.domain.models.catalog import RuntimeKind, ServiceSpecification from srm.domain.models.runtime_inventory import CapabilityInstanceState, ServiceInstance from srm.domain.models.runtime_inventory.enums import ServiceInstanceState from srm.domain.models.topology import ( CapabilityKind, CapabilityState, Loading Loading @@ -82,6 +83,13 @@ class InMemoryZoneRepository(ZoneRepository): found = self.rows.get(id) return found.model_copy(deep=True) if found is not None else None async def list_active_resource_zones(self) -> list[Zone]: return [ zone.model_copy(deep=True) for zone in self.rows.values() if zone.kind == ZoneKind.RESOURCE and zone.state == ZoneState.ACTIVE ] async def create(self, zone: Zone) -> Zone: if zone.id in self.rows: raise DuplicateEntryError() Loading @@ -98,6 +106,16 @@ class InMemoryServiceInstanceRepository(ServiceInstanceRepository): found = self.rows.get(id) return found.model_copy(deep=True) if found is not None else None async def list_by_originating_service_order_id( self, originating_service_order_id: UUID, ) -> list[ServiceInstance]: return [ row.model_copy(deep=True) for row in self.rows.values() if row.originating_service_order_id == originating_service_order_id ] async def create(self, service_instance: ServiceInstance) -> ServiceInstance: if service_instance.id in self.rows: raise DuplicateServiceInstanceError() Loading @@ -117,6 +135,18 @@ class InMemoryServiceInstanceRepository(ServiceInstanceRepository): self.rows[stored.id] = stored return stored.model_copy(deep=True) async def update_state( self, id: UUID, state: ServiceInstanceState, ) -> ServiceInstance: found = self.rows.get(id) if found is None: raise KeyError(id) updated = found.model_copy(update={"state": state}, deep=True) self.rows[id] = updated return updated.model_copy(deep=True) class FakeTransformationFunctionAdapter(TransformationFunctionExecutionPort): def get_zones(self, kind: ZoneKind | None = None) -> list[TransformationFunctionZone]: Loading