Loading src/open_exposure_gateway/adapters/database/repos/deployments.py +12 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,18 @@ class SqlAppDeploymentRepository(AppDeploymentRepository): row = await self._session.scalar(stmt) return AppDeploymentMapper.to_domain(row) if row is not None else None async def list_by_app_registration_id(self, app_registration_id: UUID) -> list[AppDeployment]: stmt = select(AppDeploymentRow).where( AppDeploymentRow.app_registration_id == app_registration_id ) rows = await self._session.scalars(stmt) return [AppDeploymentMapper.to_domain(row) for row in rows] async def list_all(self) -> list[AppDeployment]: stmt = select(AppDeploymentRow) rows = await self._session.scalars(stmt) return [AppDeploymentMapper.to_domain(row) for row in rows] async def save(self, app_deployment: AppDeployment) -> AppDeployment: merged = await self._session.merge(AppDeploymentMapper.to_row(app_deployment)) await self._session.flush() Loading src/open_exposure_gateway/api/camara/edge_application_management/vwip/schemas.py +8 −0 Original line number Diff line number Diff line Loading @@ -293,3 +293,11 @@ class CreateAppDeploymentRequest(BaseModel): class AppDeploymentId(BaseModel): appDeploymentId: UUID class AppDeploymentInfo(BaseModel): appDeploymentName: str appDeploymentId: UUID appId: UUID edgeCloudZones: list[UUID] = Field(max_length=100) appInstances: list[UUID] = Field(max_length=100) src/open_exposure_gateway/ports/database/deployments.py +8 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,14 @@ class AppDeploymentRepository(ABC): async def get_by_operation_id(self, operation_id: UUID) -> AppDeployment | None: pass @abstractmethod async def list_by_app_registration_id(self, app_registration_id: UUID) -> list[AppDeployment]: pass @abstractmethod async def list_all(self) -> list[AppDeployment]: pass @abstractmethod async def save(self, app_deployment: AppDeployment) -> AppDeployment: pass tests/unit/fakes.py +10 −0 Original line number Diff line number Diff line Loading @@ -505,6 +505,16 @@ class FakeAppDeploymentRepository(AppDeploymentRepository): return row.model_copy(deep=True) return None async def list_by_app_registration_id(self, app_registration_id: UUID) -> list[AppDeployment]: return [ row.model_copy(deep=True) for row in self.rows.values() if row.app_registration_id == app_registration_id ] async def list_all(self) -> list[AppDeployment]: return [row.model_copy(deep=True) for row in self.rows.values()] async def save(self, app_deployment: AppDeployment) -> AppDeployment: stored = app_deployment.model_copy(deep=True) self.rows[stored.app_deployment_id] = stored Loading tests/unit/test_app_deployment_repo.py +41 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,47 @@ async def test_get_by_operation_id_returns_none_when_missing() -> None: assert await repo.get_by_operation_id(uuid4()) is None async def test_list_by_app_registration_id_returns_mapped_app_deployments() -> None: row = _row() session = AsyncMock(spec=AsyncSession) session.scalars.return_value = [row] repo = SqlAppDeploymentRepository(session) result = await repo.list_by_app_registration_id(row.app_registration_id) assert len(result) == 1 assert result[0].app_deployment_id == row.app_deployment_id session.scalars.assert_awaited_once() async def test_list_by_app_registration_id_returns_empty_when_none_match() -> None: session = AsyncMock(spec=AsyncSession) session.scalars.return_value = [] repo = SqlAppDeploymentRepository(session) assert await repo.list_by_app_registration_id(uuid4()) == [] async def test_list_all_returns_every_mapped_app_deployment() -> None: rows = [_row(), _row()] session = AsyncMock(spec=AsyncSession) session.scalars.return_value = rows repo = SqlAppDeploymentRepository(session) result = await repo.list_all() assert {r.app_deployment_id for r in result} == {r.app_deployment_id for r in rows} session.scalars.assert_awaited_once() async def test_list_all_returns_empty_when_no_rows() -> None: session = AsyncMock(spec=AsyncSession) session.scalars.return_value = [] repo = SqlAppDeploymentRepository(session) assert await repo.list_all() == [] async def test_save_flushes_and_reloads_app_deployment() -> None: domain = _domain() expected = _domain() Loading Loading
src/open_exposure_gateway/adapters/database/repos/deployments.py +12 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,18 @@ class SqlAppDeploymentRepository(AppDeploymentRepository): row = await self._session.scalar(stmt) return AppDeploymentMapper.to_domain(row) if row is not None else None async def list_by_app_registration_id(self, app_registration_id: UUID) -> list[AppDeployment]: stmt = select(AppDeploymentRow).where( AppDeploymentRow.app_registration_id == app_registration_id ) rows = await self._session.scalars(stmt) return [AppDeploymentMapper.to_domain(row) for row in rows] async def list_all(self) -> list[AppDeployment]: stmt = select(AppDeploymentRow) rows = await self._session.scalars(stmt) return [AppDeploymentMapper.to_domain(row) for row in rows] async def save(self, app_deployment: AppDeployment) -> AppDeployment: merged = await self._session.merge(AppDeploymentMapper.to_row(app_deployment)) await self._session.flush() Loading
src/open_exposure_gateway/api/camara/edge_application_management/vwip/schemas.py +8 −0 Original line number Diff line number Diff line Loading @@ -293,3 +293,11 @@ class CreateAppDeploymentRequest(BaseModel): class AppDeploymentId(BaseModel): appDeploymentId: UUID class AppDeploymentInfo(BaseModel): appDeploymentName: str appDeploymentId: UUID appId: UUID edgeCloudZones: list[UUID] = Field(max_length=100) appInstances: list[UUID] = Field(max_length=100)
src/open_exposure_gateway/ports/database/deployments.py +8 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,14 @@ class AppDeploymentRepository(ABC): async def get_by_operation_id(self, operation_id: UUID) -> AppDeployment | None: pass @abstractmethod async def list_by_app_registration_id(self, app_registration_id: UUID) -> list[AppDeployment]: pass @abstractmethod async def list_all(self) -> list[AppDeployment]: pass @abstractmethod async def save(self, app_deployment: AppDeployment) -> AppDeployment: pass
tests/unit/fakes.py +10 −0 Original line number Diff line number Diff line Loading @@ -505,6 +505,16 @@ class FakeAppDeploymentRepository(AppDeploymentRepository): return row.model_copy(deep=True) return None async def list_by_app_registration_id(self, app_registration_id: UUID) -> list[AppDeployment]: return [ row.model_copy(deep=True) for row in self.rows.values() if row.app_registration_id == app_registration_id ] async def list_all(self) -> list[AppDeployment]: return [row.model_copy(deep=True) for row in self.rows.values()] async def save(self, app_deployment: AppDeployment) -> AppDeployment: stored = app_deployment.model_copy(deep=True) self.rows[stored.app_deployment_id] = stored Loading
tests/unit/test_app_deployment_repo.py +41 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,47 @@ async def test_get_by_operation_id_returns_none_when_missing() -> None: assert await repo.get_by_operation_id(uuid4()) is None async def test_list_by_app_registration_id_returns_mapped_app_deployments() -> None: row = _row() session = AsyncMock(spec=AsyncSession) session.scalars.return_value = [row] repo = SqlAppDeploymentRepository(session) result = await repo.list_by_app_registration_id(row.app_registration_id) assert len(result) == 1 assert result[0].app_deployment_id == row.app_deployment_id session.scalars.assert_awaited_once() async def test_list_by_app_registration_id_returns_empty_when_none_match() -> None: session = AsyncMock(spec=AsyncSession) session.scalars.return_value = [] repo = SqlAppDeploymentRepository(session) assert await repo.list_by_app_registration_id(uuid4()) == [] async def test_list_all_returns_every_mapped_app_deployment() -> None: rows = [_row(), _row()] session = AsyncMock(spec=AsyncSession) session.scalars.return_value = rows repo = SqlAppDeploymentRepository(session) result = await repo.list_all() assert {r.app_deployment_id for r in result} == {r.app_deployment_id for r in rows} session.scalars.assert_awaited_once() async def test_list_all_returns_empty_when_no_rows() -> None: session = AsyncMock(spec=AsyncSession) session.scalars.return_value = [] repo = SqlAppDeploymentRepository(session) assert await repo.list_all() == [] async def test_save_flushes_and_reloads_app_deployment() -> None: domain = _domain() expected = _domain() Loading