Query order history via the db.session

The query then runs in the same transaction as the `db.session`

For that, `addresses_mock` now replaces only `session.query()`
instead of the whole `db.session`.
This commit is contained in:
Alexander Hess 2026-11-30 13:43:38 +01:00
commit e9dbf528d7
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
2 changed files with 3 additions and 3 deletions

View file

@ -141,7 +141,7 @@ class OrderHistory:
start_at; start_at;
""", # noqa:S608 """, # noqa:S608
), ),
con=db.connection, con=db.session.connection(),
index_col=["pixel_id", "start_at"], index_col=["pixel_id", "start_at"],
) )

View file

@ -17,7 +17,7 @@ class TestAggregateOrders:
""" """
@pytest.fixture @pytest.fixture
def addresses_mock(self, mocker, monkeypatch): def addresses_mock(self, db_session, mocker, monkeypatch):
"""A `Mock` whose `.return_value` are to be set ... """A `Mock` whose `.return_value` are to be set ...
... to the addresses that are gridified. The addresses are ... to the addresses that are gridified. The addresses are
@ -29,7 +29,7 @@ class TestAggregateOrders:
query = ( query = (
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501 mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
) )
monkeypatch.setattr(db, "session", mock) monkeypatch.setattr(db_session, "query", mock.query)
return query return query