34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from authentic2.manager.tables import UserTable
|
|
from authentic2.manager.user_views import UsersView
|
|
from utils import login
|
|
|
|
from authentic2_cut.apps import AppConfig
|
|
|
|
|
|
def test_a2_hook_manager_modify_table(db, rf, admin, monkeypatch, app):
|
|
class DummyModule:
|
|
__path__ = [
|
|
'./dummy',
|
|
]
|
|
|
|
dummy = DummyModule()
|
|
app_config = AppConfig('authentic2_cut', dummy)
|
|
user_table = UserTable(data={})
|
|
request = rf.get('/manage/users/')
|
|
request.user = admin
|
|
users_view = UsersView.as_view()(request)
|
|
|
|
# base table contains a2 generic column
|
|
assert 'get_full_name' in list(user_table.sequence)
|
|
assert len(list(user_table.sequence)) == 6
|
|
assert 'get_full_name' in user_table.base_columns
|
|
assert len(list(user_table.base_columns)) == 6
|
|
|
|
# does not crash when explicitely run
|
|
app_config.a2_hook_manager_modify_table(users_view, user_table)
|
|
|
|
# and most of all the rendered table does not contain any such column
|
|
response = login(app, admin, '/manage/users/')
|
|
assert 'get_full_name' not in response.html
|
|
assert len(response.pyquery.find('thead').find('tr').children()) == 5
|