File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ Unreleased
1616
1717*
1818
19+ 0.17.1 - 2025-11-14
20+ ********************
21+
22+ Fixed
23+ =====
24+
25+ * Avoid circular import of AuthzEnforcer.
26+
19270.17.0 - 2025-11-14
2028********************
2129
Original file line number Diff line number Diff line change 44
55import os
66
7- __version__ = "0.17.0 "
7+ __version__ = "0.17.1 "
88
99ROOT_DIRECTORY = os .path .dirname (os .path .abspath (__file__ ))
Original file line number Diff line number Diff line change 2222from django .conf import settings
2323
2424from openedx_authz .engine .adapter import ExtendedAdapter
25- from openedx_authz .engine .matcher import is_admin_or_superuser_check
2625
2726
2827def libraries_v2_enabled () -> bool :
@@ -201,6 +200,9 @@ def _initialize_enforcer(cls) -> SyncedEnforcer:
201200 Returns:
202201 SyncedEnforcer: Configured Casbin enforcer with adapter and auto-sync
203202 """
203+ # Avoid circular import
204+ from openedx_authz .engine .matcher import is_admin_or_superuser_check # pylint: disable=import-outside-toplevel
205+
204206 db_alias = getattr (settings , "CASBIN_DB_ALIAS" , "default" )
205207
206208 try :
Original file line number Diff line number Diff line change 1+ """Test module imports."""
2+ import sys
3+ from unittest import TestCase
4+
5+
6+ class TestImports (TestCase ):
7+ """Test that imports work correctly."""
8+
9+ def setUp (self ):
10+ """Remove cached modules to ensure fresh imports and detect circular dependencies.
11+ """
12+ super ().setUp ()
13+
14+ # List of modules to remove from cache to test fresh imports
15+ modules_to_clear = [
16+ 'openedx_authz.engine.enforcer' ,
17+ 'openedx_authz.engine.matcher' ,
18+ 'openedx_authz.engine.adapter' ,
19+ 'openedx_authz.api' ,
20+ 'openedx_authz.api.permissions' ,
21+ 'openedx_authz.api.roles' ,
22+ 'openedx_authz.api.users' ,
23+ 'openedx_authz.api.data' ,
24+ ]
25+
26+ for module_name in modules_to_clear :
27+ if module_name in sys .modules :
28+ del sys .modules [module_name ]
29+
30+ def test_import_authzenforcer (self ):
31+ """Test that AuthzEnforcer can be imported."""
32+ from openedx_authz .engine .enforcer import AuthzEnforcer # pylint: disable=import-outside-toplevel
33+ try :
34+ self .assertIsNotNone (AuthzEnforcer )
35+ except ImportError as e :
36+ self .fail (f"Failed to import AuthzEnforcer: { e } " )
You can’t perform that action at this time.
0 commit comments