Skip to content

Commit

Permalink
[MIG] session_db: migration to 18.0 from 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Oct 7, 2024
1 parent a5bf7ca commit 7d2e3d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion session_db/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Store sessions in DB",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Odoo SA,ACSONE SA/NV,Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/server-tools",
Expand Down
9 changes: 8 additions & 1 deletion session_db/tests/test_pg_session_store.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from unittest import mock

import psycopg2
Expand Down Expand Up @@ -48,7 +49,10 @@ def test_session_crud(self):

def test_retry(self):
"""Test that session operations are retried before failing"""
with mock.patch("odoo.sql_db.Cursor.execute") as mock_execute:
with (
mock.patch("odoo.sql_db.Cursor.execute") as mock_execute,
self.assertLogs(level=logging.WARNING) as logs,
):
mock_execute.side_effect = psycopg2.OperationalError()
try:
self.session_store.get("abc")
Expand All @@ -59,6 +63,9 @@ def test_retry(self):
# in a way that interferes with the Cursor.execute mock
raise AssertionError("expected psycopg2.OperationalError")

Check warning on line 64 in session_db/tests/test_pg_session_store.py

View check run for this annotation

Codecov / codecov/patch

session_db/tests/test_pg_session_store.py#L64

Added line #L64 was not covered by tests
assert mock_execute.call_count == 5
self.assertEqual(len(logs.records), 1)
self.assertEqual(logs.records[0].levelno, logging.WARNING)
self.assertIn("operation try 5/5 failed, aborting", logs.output[0])
# when the error is resolved, it works again
self.session_store.get("abc")

Expand Down

0 comments on commit 7d2e3d8

Please sign in to comment.