Skip to content

Commit 5146d58

Browse files
lal-solutesbidoul
authored andcommitted
[FIX] session_db: Fix creation of postgres_uri in tests
with the parameter "login" in `_make_postgres_uri()` it becomes impossible to log in with the configured database, as it has to have the name "user". This is because of passing the `connection_info` dict as keywords parameter into the function. But because `connection_info_for` called in `setUp()` reads the config file of odoo and there the database user is `db_user` the keyword parameter is discarded and `login` is not set. The `db_`-prefix is removed. So user and password are not applied to the uri/dsn and thus login to the database is not possible, if the database wants those parameters. When I applied this change in our internal CI of solute.de, everything worked fine afterwards. This has to be ported to 17.0 and 18.0 as well.
1 parent de3ec33 commit 5146d58

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

session_db/tests/test_pg_session_store.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313

1414
def _make_postgres_uri(
15-
login=None, password=None, host=None, port=None, database=None, **kwargs
15+
user=None, password=None, host=None, port=None, database=None, **kwargs
1616
):
1717
uri = ["postgres://"]
18-
if login:
19-
uri.append(login)
18+
if user:
19+
uri.append(user)
2020
if password:
2121
uri.append(f":{password}")
2222
uri.append("@")
@@ -88,3 +88,15 @@ def test_retry_connect_fail(self):
8888
assert mock_execute.call_count == 1
8989
# when the error is resolved, it works again
9090
self.session_store.get("abc")
91+
92+
def test_make_postgres_uri(self):
93+
connection_info = {
94+
"host": "localhost",
95+
"port": 5432,
96+
"database": "test",
97+
"user": "test",
98+
"password": "PASSWORD",
99+
}
100+
assert "postgres://test:PASSWORD@localhost:5432/test" == _make_postgres_uri(
101+
**connection_info
102+
)

0 commit comments

Comments
 (0)