File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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"\n Testing 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__ } "
You can’t perform that action at this time.
0 commit comments