import pytest
from typing import Optional

from sqlmodel import Field, Session, SQLModel, create_engine
from sqlalchemy.exc import IntegrityError


def test_should_allow_duplicate_row_if_unique_constraint_is_not_passed(clear_sqlmodel):
    class Hero(SQLModel, table=True):
        id: Optional[int] = Field(default=None, primary_key=True)
        name: str
        secret_name: str
        age: Optional[int] = None

    hero_1 = Hero(name="Deadpond", secret_name="<NAME>")
    hero_2 = Hero(name="Deadpond", secret_name="<NAME>")

    engine = create_engine("sqlite://")

    