Skip to content

Commit 9ec8b65

Browse files
author
Sergio García Prado
committed
ISSUE #367
* Remove `notifications` from `DatabaseClient`.
1 parent aa324b3 commit 9ec8b65

File tree

5 files changed

+2
-47
lines changed
  • packages/core

5 files changed

+2
-47
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
ABC,
77
abstractmethod,
88
)
9-
from asyncio import (
10-
Queue,
11-
)
129
from collections.abc import (
1310
AsyncIterator,
1411
)
@@ -90,19 +87,6 @@ def fetch_all(self, *args, **kwargs) -> AsyncIterator[Any]:
9087
def _fetch_all(self, *args, **kwargs) -> AsyncIterator[Any]:
9188
raise NotImplementedError
9289

93-
@property
94-
def notifications(self) -> Queue:
95-
"""Get the notifications queue.
96-
97-
:return: A ``Queue`` instance.
98-
"""
99-
return self._notifications
100-
101-
@property
102-
@abstractmethod
103-
def _notifications(self) -> Queue:
104-
raise NotImplementedError
105-
10690

10791
class DatabaseClientBuilder(Builder[DatabaseClient]):
10892
"""Database Client Builder class."""

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
Connection,
1919
Cursor,
2020
)
21-
from aiopg.utils import (
22-
ClosableQueue,
23-
)
2421
from psycopg2 import (
2522
IntegrityError,
2623
OperationalError,
@@ -194,10 +191,6 @@ def cursor(self) -> Optional[Cursor]:
194191
"""
195192
return self._cursor
196193

197-
@property
198-
def _notifications(self) -> ClosableQueue:
199-
return self._connection.notifies
200-
201194
@property
202195
def connection(self) -> Optional[Connection]:
203196
"""Get the connection.

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

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
from abc import (
33
ABC,
44
)
5-
from asyncio import (
6-
Queue,
7-
)
85
from typing import (
96
Any,
107
AsyncIterator,
118
)
129
from unittest.mock import (
1310
AsyncMock,
1411
MagicMock,
15-
PropertyMock,
1612
call,
17-
patch,
1813
)
1914

2015
from minos.common import (
@@ -44,16 +39,11 @@ async def _execute(self, *args, **kwargs) -> None:
4439
def _fetch_all(self, *args, **kwargs) -> AsyncIterator[Any]:
4540
"""For testing purposes."""
4641

47-
# noinspection PyPropertyDefinition
48-
@property
49-
def _notifications(self) -> Queue:
50-
"""For testing purposes."""
51-
5242

5343
class TestDatabaseClient(unittest.IsolatedAsyncioTestCase):
5444
def test_abstract(self):
5545
self.assertTrue(issubclass(DatabaseClient, (ABC, BuildableMixin)))
56-
expected = {"_notifications", "_is_valid", "_execute", "_fetch_all", "_reset"}
46+
expected = {"_is_valid", "_execute", "_fetch_all", "_reset"}
5747
# noinspection PyUnresolvedReferences
5848
self.assertEqual(expected, DatabaseClient.__abstractmethods__)
5949

@@ -106,14 +96,6 @@ async def test_fetch_one(self):
10696

10797
self.assertEqual([call()], mock.call_args_list)
10898

109-
async def test_notifications(self):
110-
expected = Queue()
111-
client = _DatabaseClient()
112-
with patch.object(_DatabaseClient, "_notifications", new_callable=PropertyMock, return_value=expected) as mock:
113-
self.assertEqual(expected, client.notifications)
114-
115-
self.assertEqual([call()], mock.call_args_list)
116-
11799

118100
class TestDatabaseClientBuilder(CommonTestCase):
119101
def test_with_name(self):

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ async def test_connection_raises(self):
8383
async with AiopgDatabaseClient.from_config(self.config):
8484
pass
8585

86-
async def test_notifications(self):
87-
async with AiopgDatabaseClient.from_config(self.config) as client:
88-
self.assertEqual(client.connection.notifies, client.notifications)
89-
9086
async def test_cursor(self):
9187
client = AiopgDatabaseClient.from_config(self.config)
9288
self.assertIsNone(client.cursor)

packages/core/minos-microservice-networks/minos/networks/brokers/collections/queues/pg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def _wait_for_entries(self, client: DatabaseClient, max_wait: Optional[flo
197197
return
198198

199199
with suppress(TimeoutError):
200-
return await wait_for(consume_queue(client.notifications, self._records), max_wait)
200+
return await wait_for(consume_queue(client.connection.notifies, self._records), max_wait)
201201

202202
async def _get_count(self, client: DatabaseClient) -> int:
203203
# noinspection PyTypeChecker

0 commit comments

Comments
 (0)