diff --git a/packages/core/minos-microservice-common/minos/common/database/clients/abc.py b/packages/core/minos-microservice-common/minos/common/database/clients/abc.py index b878b301a..dfa38e273 100644 --- a/packages/core/minos-microservice-common/minos/common/database/clients/abc.py +++ b/packages/core/minos-microservice-common/minos/common/database/clients/abc.py @@ -99,11 +99,14 @@ async def execute(self, operation: DatabaseOperation) -> None: await self._create_lock(operation.lock) if isinstance(operation, ComposedDatabaseOperation): - for op in operation.operations: - await wait_for(self._execute(op), operation.timeout) + await wait_for(self._execute_composed(operation), operation.timeout) else: await wait_for(self._execute(operation), operation.timeout) + async def _execute_composed(self, operation: ComposedDatabaseOperation) -> None: + for op in operation.operations: + await self.execute(op) + @abstractmethod async def _execute(self, operation: DatabaseOperation) -> None: raise NotImplementedError diff --git a/packages/core/minos-microservice-common/tests/test_common/test_database/test_clients/test_abc.py b/packages/core/minos-microservice-common/tests/test_common/test_database/test_clients/test_abc.py index fbedcca2c..70dc2207a 100644 --- a/packages/core/minos-microservice-common/tests/test_common/test_database/test_clients/test_abc.py +++ b/packages/core/minos-microservice-common/tests/test_common/test_database/test_clients/test_abc.py @@ -133,13 +133,15 @@ async def test_execute(self): self.assertEqual([call(operation)], mock.call_args_list) async def test_execute_composed(self): - mock = AsyncMock() client = _DatabaseClient() - client._execute = mock + mock = AsyncMock(side_effect=client.execute) + client.execute = mock composed = ComposedDatabaseOperation([_DatabaseOperation(), _DatabaseOperation()]) await client.execute(composed) - self.assertEqual([call(composed.operations[0]), call(composed.operations[1])], mock.call_args_list) + self.assertEqual( + [call(composed), call(composed.operations[0]), call(composed.operations[1])], mock.call_args_list + ) async def test_execute_with_lock(self): op1 = _DatabaseOperation(lock="foo")