Query with select() in Pixel
`Session.query()` is the legacy API in SQLAlchemy 2.x. The addresses with restaurants are now selected with a subquery in one statement. The `_restaurants_mock` fixture mocks the new call chain.
This commit is contained in:
parent
0dc3e11a63
commit
2eb6b5769f
1 changed files with 32 additions and 38 deletions
|
|
@ -121,7 +121,7 @@ class TestProperties:
|
|||
def _restaurants_mock(self, mocker, monkeypatch, restaurant):
|
||||
"""A `Mock` whose `.return_value` is `[restaurant]`."""
|
||||
mock = mocker.Mock()
|
||||
query = mock.query.return_value.join.return_value.filter.return_value.all
|
||||
query = mock.scalars.return_value.all
|
||||
query.return_value = [restaurant]
|
||||
monkeypatch.setattr(db, "session", mock)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue