(app: Flask)
| 99 | |
| 100 | @pytest.mark.usefixtures("app_ctx") |
| 101 | def test_create_drop_all(app: Flask) -> None: |
| 102 | app.config["SQLALCHEMY_BINDS"] = {"a": "sqlite://"} |
| 103 | db = SQLAlchemy(app) |
| 104 | |
| 105 | class User(db.Model): |
| 106 | id = sa.Column(sa.Integer, primary_key=True) |
| 107 | |
| 108 | class Post(db.Model): |
| 109 | __bind_key__ = "a" |
| 110 | id = sa.Column(sa.Integer, primary_key=True) |
| 111 | |
| 112 | with pytest.raises(sa_exc.OperationalError): |
| 113 | db.session.execute(sa.select(User)).scalars() |
| 114 | |
| 115 | with pytest.raises(sa_exc.OperationalError): |
| 116 | db.session.execute(sa.select(Post)).scalars() |
| 117 | |
| 118 | db.create_all() |
| 119 | db.session.execute(sa.select(User)).scalars() |
| 120 | db.session.execute(sa.select(Post)).scalars() |
| 121 | db.drop_all() |
| 122 | |
| 123 | with pytest.raises(sa_exc.OperationalError): |
| 124 | db.session.execute(sa.select(User)).scalars() |
| 125 | |
| 126 | with pytest.raises(sa_exc.OperationalError): |
| 127 | db.session.execute(sa.select(Post)).scalars() |
| 128 | |
| 129 | |
| 130 | @pytest.mark.usefixtures("app_ctx") |
nothing calls this directly
no test coverage detected
searching dependent graphs…