Skip to content

Commit d5b13bf

Browse files
committed
test: add tests
1 parent 759ad10 commit d5b13bf

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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}")

0 commit comments

Comments
 (0)