Skip to content

Commit 71978f2

Browse files
author
Sergio García Prado
committed
ISSUE #367
* Remove accessors from `DatabaseMixin`.
1 parent be692f8 commit 71978f2

File tree

6 files changed

+4
-105
lines changed

6 files changed

+4
-105
lines changed

packages/core/minos-microservice-aggregate/tests/test_aggregate/test_events/test_repositories/test_pg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ def test_constructor(self):
3535
def test_from_config(self):
3636
repository = PostgreSqlEventRepository.from_config(self.config)
3737
repository_config = self.config.get_database_by_name("event")
38-
self.assertEqual(repository_config["database"], repository.database)
39-
self.assertEqual(repository_config["user"], repository.user)
40-
self.assertEqual(repository_config["password"], repository.password)
41-
self.assertEqual(repository_config["host"], repository.host)
42-
self.assertEqual(repository_config["port"], repository.port)
38+
self.assertEqual(repository_config["database"], repository.pool.database)
4339

4440
async def test_setup(self):
4541
async with aiopg.connect(**self.config.get_default_database()) as connection:

packages/core/minos-microservice-aggregate/tests/test_aggregate/test_snapshots/test_pg/test_readers.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ def test_type(self):
9595
def test_from_config(self):
9696
reader = PostgreSqlSnapshotReader.from_config(self.config)
9797
snapshot_config = self.config.get_database_by_name("snapshot")
98-
self.assertEqual(snapshot_config["host"], reader.host)
99-
self.assertEqual(snapshot_config["port"], reader.port)
100-
self.assertEqual(snapshot_config["database"], reader.database)
101-
self.assertEqual(snapshot_config["user"], reader.user)
102-
self.assertEqual(snapshot_config["password"], reader.password)
98+
self.assertEqual(snapshot_config["database"], reader.pool.database)
10399

104100
async def test_find_by_uuid(self):
105101
condition = Condition.IN("uuid", [self.uuid_2, self.uuid_3])

packages/core/minos-microservice-aggregate/tests/test_aggregate/test_snapshots/test_pg/test_writers.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ def test_type(self):
102102

103103
def test_from_config(self):
104104
snapshot_config = self.config.get_database_by_name("snapshot")
105-
self.assertEqual(snapshot_config["host"], self.writer.host)
106-
self.assertEqual(snapshot_config["port"], self.writer.port)
107-
self.assertEqual(snapshot_config["database"], self.writer.database)
108-
self.assertEqual(snapshot_config["user"], self.writer.user)
109-
self.assertEqual(snapshot_config["password"], self.writer.password)
105+
self.assertEqual(snapshot_config["database"], self.writer.pool.database)
110106

111107
def test_from_config_raises(self):
112108
with self.assertRaises(NotProvidedException):

packages/core/minos-microservice-aggregate/tests/test_aggregate/test_transactions/test_repositories/test_pg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ def test_constructor(self):
5151
def test_from_config(self):
5252
repository = PostgreSqlTransactionRepository.from_config(self.config)
5353
repository_config = self.config.get_database_by_name("event")
54-
self.assertEqual(repository_config["host"], repository.host)
55-
self.assertEqual(repository_config["port"], repository.port)
56-
self.assertEqual(repository_config["database"], repository.database)
57-
self.assertEqual(repository_config["user"], repository.user)
58-
self.assertEqual(repository_config["password"], repository.password)
54+
self.assertEqual(repository_config["database"], repository.pool.database)
5955

6056
async def test_setup(self):
6157
async with aiopg.connect(**self.config.get_default_database()) as connection:

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -62,51 +62,6 @@ def __init__(
6262

6363
self._pool = database_pool
6464

65-
@property
66-
def database(self) -> str:
67-
"""Get the database's database.
68-
69-
:return: A ``str`` value.
70-
"""
71-
warnings.warn("'database' has been deprecated. Use 'pool.database' instead.", DeprecationWarning)
72-
return self.pool.database
73-
74-
@property
75-
def host(self) -> str:
76-
"""Get the database's host.
77-
78-
:return: A ``str`` value.
79-
"""
80-
warnings.warn("'host' has been deprecated. Use 'pool.host' instead.", DeprecationWarning)
81-
return self.pool.host
82-
83-
@property
84-
def port(self) -> int:
85-
"""Get the database's port.
86-
87-
:return: An ``int`` value.
88-
"""
89-
warnings.warn("'port' has been deprecated. Use 'pool.port' instead.", DeprecationWarning)
90-
return self.pool.port
91-
92-
@property
93-
def user(self) -> str:
94-
"""Get the database's user.
95-
96-
:return: A ``str`` value.
97-
"""
98-
warnings.warn("'user' has been deprecated. Use 'pool.user' instead.", DeprecationWarning)
99-
return self.pool.user
100-
101-
@property
102-
def password(self) -> str:
103-
"""Get the database's password.
104-
105-
:return: A ``str`` value.
106-
"""
107-
warnings.warn("'password' has been deprecated. Use 'pool.password' instead.", DeprecationWarning)
108-
return self.pool.password
109-
11065
async def submit_query_and_fetchone(self, *args, **kwargs) -> tuple:
11166
"""Submit a SQL query and gets the first response.
11267

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -47,46 +47,6 @@ async def test_constructor_with_postgresql_pool(self):
4747

4848
self.assertEqual(pool, database.pool)
4949

50-
def test_database(self):
51-
pool = DatabaseClientPool.from_config(self.config)
52-
database = DatabaseMixin(pool)
53-
with warnings.catch_warnings():
54-
warnings.simplefilter("ignore", DeprecationWarning)
55-
# noinspection PyDeprecation
56-
self.assertEqual(pool.database, database.database)
57-
58-
def test_user(self):
59-
pool = DatabaseClientPool.from_config(self.config)
60-
database = DatabaseMixin(pool)
61-
with warnings.catch_warnings():
62-
warnings.simplefilter("ignore", DeprecationWarning)
63-
# noinspection PyDeprecation
64-
self.assertEqual(pool.user, database.user)
65-
66-
def test_password(self):
67-
pool = DatabaseClientPool.from_config(self.config)
68-
database = DatabaseMixin(pool)
69-
with warnings.catch_warnings():
70-
warnings.simplefilter("ignore", DeprecationWarning)
71-
# noinspection PyDeprecation
72-
self.assertEqual(pool.password, database.password)
73-
74-
def test_host(self):
75-
pool = DatabaseClientPool.from_config(self.config)
76-
database = DatabaseMixin(pool)
77-
with warnings.catch_warnings():
78-
warnings.simplefilter("ignore", DeprecationWarning)
79-
# noinspection PyDeprecation
80-
self.assertEqual(pool.host, database.host)
81-
82-
def test_port(self):
83-
pool = DatabaseClientPool.from_config(self.config)
84-
database = DatabaseMixin(pool)
85-
with warnings.catch_warnings():
86-
warnings.simplefilter("ignore", DeprecationWarning)
87-
# noinspection PyDeprecation
88-
self.assertEqual(pool.port, database.port)
89-
9050
async def test_pool(self):
9151
async with DatabaseMixin() as database:
9252
self.assertIsInstance(database.pool, DatabaseClientPool)

0 commit comments

Comments
 (0)