Loading src/open_exposure_gateway/application/services/edge_application_management_service.py +7 −0 Changes for src/open_exposure_gateway/application/services/edge_application_management_service.py: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -698,6 +698,9 @@ class EdgeApplicationManagementService: if app_registration is None: raise BadRequestException(message=f"App {request.appId} is not registered") if len(set(request.edgeCloudZones)) != len(request.edgeCloudZones): raise BadRequestException(message="edgeCloudZones must not contain duplicates") for zone_id in request.edgeCloudZones: if await self._app_instance_repo.exists_in_zone( app_registration.app_registration_id, zone_id Loading Loading @@ -1118,6 +1121,8 @@ class EdgeApplicationManagementService: "operation_completed_for_unknown_operation", operation_id=event.operation_id ) return if operation.operation_type not in _RECONCILABLE_OPERATION_TYPES: return if operation.status in _TERMINAL_OPERATION_STATUSES: logger.info( Loading Loading @@ -1323,6 +1328,8 @@ class EdgeApplicationManagementService: "operation_status_for_unknown_operation", operation_id=event.operation_id ) return if operation.operation_type not in _RECONCILABLE_OPERATION_TYPES: return if operation.status in _TERMINAL_OPERATION_STATUSES: logger.info( Loading tests/unit/test_eam_service.py +34 −0 Changes for tests/unit/test_eam_service.py: 34 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1438,6 +1438,20 @@ class TestCreateAppDeployment: assert app_deployment_repo.rows == {} assert app_instance_repo.rows == {} async def test_same_zone_twice_in_one_request_is_rejected( self, service: EdgeApplicationManagementService, publisher: AsyncMock, app_instance_repo: FakeAppInstanceRepository, ) -> None: request = self._make_request(zones=[self.ZONE_A, self.ZONE_A]) with pytest.raises(BadRequestException, match="duplicates"): await service.create_app_deployment( request=request, tenant_id="tenant-1", app_provider_id="provider-1" ) publisher.publish.assert_not_called() assert app_instance_repo.rows == {} def _make_request_with_subscription( self, with_credential: bool = False ) -> CreateAppDeploymentRequest: Loading Loading @@ -4636,6 +4650,26 @@ class TestHandleOperationStatus: assert await operation_repo.get_by_id(unknown_operation_id) is None @pytest.mark.parametrize("state", ["accepted", "failed", "failed_before_start"]) async def test_status_for_qod_operation_is_noop( self, service: EdgeApplicationManagementService, operation_repo: FakeOperationRepository, state: Literal["accepted", "failed", "failed_before_start"], ) -> None: await self._seed_operation( operation_repo, OperationStatus.PENDING, operation_type=OperationType.NETWORK_CAPABILITY, ) await service.handle_operation_status(self._status_event(state)) untouched = await operation_repo.get_by_id(self.OPERATION_ID) assert untouched is not None assert untouched.status == OperationStatus.PENDING assert untouched.error is None @pytest.mark.parametrize("failure_state", ["failed", "failed_before_start"]) async def test_failure_state_moves_pending_deploy_operation_and_instance_to_failed( self, Loading Loading
src/open_exposure_gateway/application/services/edge_application_management_service.py +7 −0 Changes for src/open_exposure_gateway/application/services/edge_application_management_service.py: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -698,6 +698,9 @@ class EdgeApplicationManagementService: if app_registration is None: raise BadRequestException(message=f"App {request.appId} is not registered") if len(set(request.edgeCloudZones)) != len(request.edgeCloudZones): raise BadRequestException(message="edgeCloudZones must not contain duplicates") for zone_id in request.edgeCloudZones: if await self._app_instance_repo.exists_in_zone( app_registration.app_registration_id, zone_id Loading Loading @@ -1118,6 +1121,8 @@ class EdgeApplicationManagementService: "operation_completed_for_unknown_operation", operation_id=event.operation_id ) return if operation.operation_type not in _RECONCILABLE_OPERATION_TYPES: return if operation.status in _TERMINAL_OPERATION_STATUSES: logger.info( Loading Loading @@ -1323,6 +1328,8 @@ class EdgeApplicationManagementService: "operation_status_for_unknown_operation", operation_id=event.operation_id ) return if operation.operation_type not in _RECONCILABLE_OPERATION_TYPES: return if operation.status in _TERMINAL_OPERATION_STATUSES: logger.info( Loading
tests/unit/test_eam_service.py +34 −0 Changes for tests/unit/test_eam_service.py: 34 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1438,6 +1438,20 @@ class TestCreateAppDeployment: assert app_deployment_repo.rows == {} assert app_instance_repo.rows == {} async def test_same_zone_twice_in_one_request_is_rejected( self, service: EdgeApplicationManagementService, publisher: AsyncMock, app_instance_repo: FakeAppInstanceRepository, ) -> None: request = self._make_request(zones=[self.ZONE_A, self.ZONE_A]) with pytest.raises(BadRequestException, match="duplicates"): await service.create_app_deployment( request=request, tenant_id="tenant-1", app_provider_id="provider-1" ) publisher.publish.assert_not_called() assert app_instance_repo.rows == {} def _make_request_with_subscription( self, with_credential: bool = False ) -> CreateAppDeploymentRequest: Loading Loading @@ -4636,6 +4650,26 @@ class TestHandleOperationStatus: assert await operation_repo.get_by_id(unknown_operation_id) is None @pytest.mark.parametrize("state", ["accepted", "failed", "failed_before_start"]) async def test_status_for_qod_operation_is_noop( self, service: EdgeApplicationManagementService, operation_repo: FakeOperationRepository, state: Literal["accepted", "failed", "failed_before_start"], ) -> None: await self._seed_operation( operation_repo, OperationStatus.PENDING, operation_type=OperationType.NETWORK_CAPABILITY, ) await service.handle_operation_status(self._status_event(state)) untouched = await operation_repo.get_by_id(self.OPERATION_ID) assert untouched is not None assert untouched.status == OperationStatus.PENDING assert untouched.error is None @pytest.mark.parametrize("failure_state", ["failed", "failed_before_start"]) async def test_failure_state_moves_pending_deploy_operation_and_instance_to_failed( self, Loading