Skip to content

Commit e9e37fe

Browse files
Copilotnomeguy
andcommitted
Add compatibility test for SQLAlchemy version support
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent 946c21f commit e9e37fe

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/test_compatibility.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Test compatibility with different SQLAlchemy versions.
3+
4+
This test ensures the adapter works with both SQLAlchemy 1.4.x and 2.x.
5+
"""
6+
import sqlalchemy
7+
from casbin import Enforcer
8+
from databases import Database
9+
10+
11+
async def test_sqlalchemy_version_info(db: Database, enforcer: Enforcer):
12+
"""Test that reports which SQLAlchemy version is being used."""
13+
print(f"\nTesting with SQLAlchemy version: {sqlalchemy.__version__}")
14+
15+
# Verify basic enforcement works
16+
assert enforcer.enforce("alice", "data1", "read") == True
17+
assert enforcer.enforce("bob", "data2", "write") == True
18+
19+
# This test should pass with both SQLAlchemy 1.4.x and 2.x
20+
major_version = int(sqlalchemy.__version__.split('.')[0])
21+
assert major_version in [1, 2], f"Unexpected SQLAlchemy version: {sqlalchemy.__version__}"

0 commit comments

Comments
 (0)