diff --git a/tests/db/test_grids.py b/tests/db/test_grids.py index 9561d43..a8bf845 100644 --- a/tests/db/test_grids.py +++ b/tests/db/test_grids.py @@ -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`."""