Skip to content

Commit 2a15cdb

Browse files
author
Sergio García Prado
committed
ISSUE #442
* Fix bug related with locking and `ComposedDatabaseOperation`.
1 parent 4f88dd7 commit 2a15cdb

File tree

2 files changed

+6
-4
lines changed
  • packages/core/minos-microservice-common
    • minos/common/database/clients
    • tests/test_common/test_database/test_clients

2 files changed

+6
-4
lines changed

packages/core/minos-microservice-common/minos/common/database/clients/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def execute(self, operation: DatabaseOperation) -> None:
100100

101101
if isinstance(operation, ComposedDatabaseOperation):
102102
for op in operation.operations:
103-
await wait_for(self._execute(op), operation.timeout)
103+
await wait_for(self.execute(op), operation.timeout)
104104
else:
105105
await wait_for(self._execute(operation), operation.timeout)
106106

packages/core/minos-microservice-common/tests/test_common/test_database/test_clients/test_abc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ async def test_execute(self):
133133
self.assertEqual([call(operation)], mock.call_args_list)
134134

135135
async def test_execute_composed(self):
136-
mock = AsyncMock()
137136
client = _DatabaseClient()
138-
client._execute = mock
137+
mock = AsyncMock(side_effect=client.execute)
138+
client.execute = mock
139139
composed = ComposedDatabaseOperation([_DatabaseOperation(), _DatabaseOperation()])
140140
await client.execute(composed)
141141

142-
self.assertEqual([call(composed.operations[0]), call(composed.operations[1])], mock.call_args_list)
142+
self.assertEqual(
143+
[call(composed), call(composed.operations[0]), call(composed.operations[1])], mock.call_args_list
144+
)
143145

144146
async def test_execute_with_lock(self):
145147
op1 = _DatabaseOperation(lock="foo")

0 commit comments

Comments
 (0)