MCPcopy
hub / github.com/pallets-eco/flask-sqlalchemy / test_create_drop_all

Function test_create_drop_all

tests/test_metadata.py:101–127  ·  view source on GitHub ↗
(app: Flask)

Source from the content-addressed store, hash-verified

99
100@pytest.mark.usefixtures("app_ctx")
101def 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")

Callers

nothing calls this directly

Calls 3

create_allMethod · 0.95
drop_allMethod · 0.95
SQLAlchemyClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…