Review the ORM models and align the live database with them #16

Merged
alexander merged 10 commits from orm-review into develop 2026-12-01 23:06:04 +01:00
Showing only changes of commit f532aae588 - Show all commits

Test grids with the same side length in different cities

Regression test for the removed `unique=True` on `Grid.side_length`.
Alexander Hess 2026-12-01 22:18:52 +01:00
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -61,6 +61,25 @@ class TestConstraints:
with pytest.raises(sa_exc.IntegrityError, match="duplicate key value"):
db_session.commit()
def test_two_grids_with_identical_side_length_in_different_cities(
self,
db_session,
grid,
city_data,
):
"""Insert two `Grid`s with the same `.side_length` in different `.city`s."""
db_session.add(grid)
db_session.commit()
# Create a `Grid` with the same `.side_length` in another `.city`.
another_city = db.City(**(city_data | {"id": 2, "name": "Lyon"}))
another_grid = db.Grid(city=another_city, side_length=grid.side_length)
db_session.add(another_grid)
db_session.commit() # no `IntegrityError`
assert another_grid.id is not None
class TestProperties:
"""Test properties in `Grid`."""