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

Function test_reflect

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

Source from the content-addressed store, hash-verified

149
150@pytest.mark.usefixtures("app_ctx")
151def test_reflect(app: Flask) -> None:
152 app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///user.db"
153 app.config["SQLALCHEMY_BINDS"] = {"post": "sqlite:///post.db"}
154 db = SQLAlchemy(app)
155 db.Table("user", sa.Column("id", sa.Integer, primary_key=True))
156 db.Table("post", sa.Column("id", sa.Integer, primary_key=True), bind_key="post")
157 db.create_all()
158
159 del app.extensions["sqlalchemy"]
160 db = SQLAlchemy(app)
161 assert not db.metadata.tables
162 db.reflect()
163 assert "user" in db.metadata.tables
164 assert "post" in db.metadatas["post"].tables

Callers

nothing calls this directly

Calls 3

create_allMethod · 0.95
reflectMethod · 0.95
SQLAlchemyClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…