Test grids with the same side length in different cities
Regression test for the removed `unique=True` on `Grid.side_length`.
This commit is contained in:
parent
b36a3d1cd6
commit
f532aae588
1 changed files with 19 additions and 0 deletions
|
|
@ -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`."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue