From e30b3efbe8fc719f7d1d5bef32c69df67884f4d7 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Mon, 30 Nov 2026 14:17:49 +0100 Subject: [PATCH] Use the `sa` alias for `sqlalchemy` everywhere `sa` is the common alias, also in SQLAlchemy's own documentation --- tests/db/replay/test_orders.py | 8 ++++---- tests/db/test_addresses.py | 4 ++-- tests/db/test_addresses_addresses.py | 10 +++++----- tests/db/test_addresses_pixels.py | 10 +++++----- tests/db/test_forecasts.py | 4 ++-- tests/db/test_grids.py | 4 ++-- tests/db/test_orders.py | 10 +++++----- tests/db/test_pixels.py | 4 ++-- tests/db/test_restaurants.py | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/db/replay/test_orders.py b/tests/db/replay/test_orders.py index 412416a..8d347f2 100644 --- a/tests/db/replay/test_orders.py +++ b/tests/db/replay/test_orders.py @@ -3,7 +3,7 @@ import datetime as dt import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from tests import config as test_config @@ -44,7 +44,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.ReplaySimulation).where( + stmt = sa.delete(db.ReplaySimulation).where( db.ReplaySimulation.id == replayed_order.simulation.id, ) @@ -60,7 +60,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Order).where(db.Order.id == replayed_order.actual.id) + stmt = sa.delete(db.Order).where(db.Order.id == replayed_order.actual.id) with pytest.raises(sa_exc.IntegrityError, match="fk_replayed_orders_to_orders"): db_session.execute(stmt) @@ -80,7 +80,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Courier).where(db.Courier.id == replayed_order.courier.id) + stmt = sa.delete(db.Courier).where(db.Courier.id == replayed_order.courier.id) with pytest.raises( sa_exc.IntegrityError, diff --git a/tests/db/test_addresses.py b/tests/db/test_addresses.py index 6c3843e..9057657 100644 --- a/tests/db/test_addresses.py +++ b/tests/db/test_addresses.py @@ -1,7 +1,7 @@ """Test the ORM's `Address` model.""" import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from velofy import db @@ -57,7 +57,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.City).where(db.City.id == address.city.id) + stmt = sa.delete(db.City).where(db.City.id == address.city.id) with pytest.raises( sa_exc.IntegrityError, diff --git a/tests/db/test_addresses_addresses.py b/tests/db/test_addresses_addresses.py index 9d9f91d..087547f 100644 --- a/tests/db/test_addresses_addresses.py +++ b/tests/db/test_addresses_addresses.py @@ -4,7 +4,7 @@ import json import googlemaps import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from geopy import distance from sqlalchemy import exc as sa_exc @@ -73,7 +73,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Address).where(db.Address.id == path.first_address.id) + stmt = sa.delete(db.Address).where(db.Address.id == path.first_address.id) with pytest.raises( sa_exc.IntegrityError, @@ -87,7 +87,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Address).where(db.Address.id == path.second_address.id) + stmt = sa.delete(db.Address).where(db.Address.id == path.second_address.id) with pytest.raises( sa_exc.IntegrityError, @@ -103,7 +103,7 @@ class TestConstraints: # Must insert without ORM as otherwise SQLAlchemy figures out # that something is wrong before any query is sent to the database. - stmt = sqla.insert(db.Path).values( + stmt = sa.insert(db.Path).values( first_address_id=address.id, second_address_id=another_address.id, city_id=999, @@ -123,7 +123,7 @@ class TestConstraints: # Must insert without ORM as otherwise SQLAlchemy figures out # that something is wrong before any query is sent to the database. - stmt = sqla.insert(db.Path).values( + stmt = sa.insert(db.Path).values( first_address_id=path.first_address.id, second_address_id=path.second_address.id, city_id=path.city_id, diff --git a/tests/db/test_addresses_pixels.py b/tests/db/test_addresses_pixels.py index 9b38caa..6fa46d9 100644 --- a/tests/db/test_addresses_pixels.py +++ b/tests/db/test_addresses_pixels.py @@ -10,7 +10,7 @@ Implementation notes: """ import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from velofy import db @@ -56,7 +56,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Address).where(db.Address.id == assoc.address.id) + stmt = sa.delete(db.Address).where(db.Address.id == assoc.address.id) with pytest.raises( sa_exc.IntegrityError, @@ -72,7 +72,7 @@ class TestConstraints: # Must insert without ORM as otherwise SQLAlchemy figures out # that something is wrong before any query is sent to the database. - stmt = sqla.insert(db.AddressPixelAssociation).values( + stmt = sa.insert(db.AddressPixelAssociation).values( address_id=address.id, city_id=999, grid_id=pixel.grid.id, @@ -93,7 +93,7 @@ class TestConstraints: # Must insert without ORM as otherwise SQLAlchemy figures out # that something is wrong before any query is sent to the database. - stmt = sqla.insert(db.AddressPixelAssociation).values( + stmt = sa.insert(db.AddressPixelAssociation).values( address_id=address.id, city_id=address.city.id, grid_id=999, @@ -112,7 +112,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Pixel).where(db.Pixel.id == assoc.pixel.id) + stmt = sa.delete(db.Pixel).where(db.Pixel.id == assoc.pixel.id) with pytest.raises( sa_exc.IntegrityError, diff --git a/tests/db/test_forecasts.py b/tests/db/test_forecasts.py index cbc9662..ba6025c 100644 --- a/tests/db/test_forecasts.py +++ b/tests/db/test_forecasts.py @@ -4,7 +4,7 @@ import datetime as dt import pandas as pd import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from tests import config as test_config @@ -76,7 +76,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Pixel).where(db.Pixel.id == forecast.pixel.id) + stmt = sa.delete(db.Pixel).where(db.Pixel.id == forecast.pixel.id) with pytest.raises( sa_exc.IntegrityError, diff --git a/tests/db/test_grids.py b/tests/db/test_grids.py index f9433c6..a0f7e30 100644 --- a/tests/db/test_grids.py +++ b/tests/db/test_grids.py @@ -1,7 +1,7 @@ """Test the ORM's `Grid` model.""" import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from velofy import db @@ -41,7 +41,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.City).where(db.City.id == grid.city.id) + stmt = sa.delete(db.City).where(db.City.id == grid.city.id) with pytest.raises( sa_exc.IntegrityError, diff --git a/tests/db/test_orders.py b/tests/db/test_orders.py index 7a8c5f5..7ad31f7 100644 --- a/tests/db/test_orders.py +++ b/tests/db/test_orders.py @@ -4,7 +4,7 @@ import datetime as dt import random import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from tests import config as test_config @@ -58,7 +58,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Customer).where(db.Customer.id == order.customer.id) + stmt = sa.delete(db.Customer).where(db.Customer.id == order.customer.id) with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_customers"): db_session.execute(stmt) @@ -69,7 +69,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Courier).where(db.Courier.id == order.courier.id) + stmt = sa.delete(db.Courier).where(db.Courier.id == order.courier.id) with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_couriers"): db_session.execute(stmt) @@ -80,7 +80,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Restaurant).where(db.Restaurant.id == order.restaurant.id) + stmt = sa.delete(db.Restaurant).where(db.Restaurant.id == order.restaurant.id) with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"): db_session.execute(stmt) @@ -112,7 +112,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Address).where(db.Address.id == order.delivery_address.id) + stmt = sa.delete(db.Address).where(db.Address.id == order.delivery_address.id) with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_addresses"): db_session.execute(stmt) diff --git a/tests/db/test_pixels.py b/tests/db/test_pixels.py index a7df8c9..bfba927 100644 --- a/tests/db/test_pixels.py +++ b/tests/db/test_pixels.py @@ -1,7 +1,7 @@ """Test the ORM's `Pixel` model.""" import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from velofy import db @@ -41,7 +41,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Grid).where(db.Grid.id == pixel.grid.id) + stmt = sa.delete(db.Grid).where(db.Grid.id == pixel.grid.id) with pytest.raises( sa_exc.IntegrityError, diff --git a/tests/db/test_restaurants.py b/tests/db/test_restaurants.py index 9b07932..a2d6b03 100644 --- a/tests/db/test_restaurants.py +++ b/tests/db/test_restaurants.py @@ -1,7 +1,7 @@ """Test the ORM's `Restaurant` model.""" import pytest -import sqlalchemy as sqla +import sqlalchemy as sa from sqlalchemy import exc as sa_exc from velofy import db @@ -41,7 +41,7 @@ class TestConstraints: db_session.commit() # Must delete without ORM as otherwise an UPDATE statement is emitted. - stmt = sqla.delete(db.Address).where(db.Address.id == restaurant.address.id) + stmt = sa.delete(db.Address).where(db.Address.id == restaurant.address.id) with pytest.raises( sa_exc.IntegrityError,