Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down