khalidmammadov commented on a change in pull request #18961:
URL: https://github.com/apache/airflow/pull/18961#discussion_r731739200
##########
File path: tests/www/views/conftest.py
##########
@@ -66,42 +66,29 @@ def factory():
app.jinja_env.undefined = jinja2.StrictUndefined
security_manager = app.appbuilder.sm
- if not security_manager.find_user(username='test'):
- security_manager.add_user(
- username='test',
- first_name='test',
- last_name='test',
- email='[email protected]',
- role=security_manager.find_role('Admin'),
- password='test',
- )
- if not security_manager.find_user(username='test_user'):
- security_manager.add_user(
- username='test_user',
- first_name='test_user',
- last_name='test_user',
- email='[email protected]',
- role=security_manager.find_role('User'),
- password='test_user',
- )
- if not security_manager.find_user(username='test_viewer'):
- security_manager.add_user(
- username='test_viewer',
- first_name='test_viewer',
- last_name='test_viewer',
- email='[email protected]',
- role=security_manager.find_role('Viewer'),
- password='test_viewer',
- )
+
+ test_users = [('test_admin', 'Admin'), ('test_user', 'User'),
('test_viewer', 'Viewer')]
+
+ for user_name, role in test_users:
+ if not security_manager.find_user(username=user_name):
+ security_manager.add_user(
+ username=user_name,
+ first_name=user_name,
+ last_name=user_name,
+ email=f'{user_name}@fab.org',
+ role=security_manager.find_role(role),
+ password=user_name,
+ )
Review comment:
Fixed with dict, still loop but allows customizations. Any better?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]