Skip to content

Commit ebbcebd

Browse files
committed
fixups
1 parent bf8c804 commit ebbcebd

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

mig/shared/useradm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
https_authdigests = user_db_filename
102102

103103

104+
_USERADM_CONFIG_DIR_KEYS = ('user_db_home', 'user_home', 'user_settings',
105+
'user_cache', 'mrsl_files_dir', 'resource_pending')
106+
107+
104108
def init_user_adm(dynamic_db_path=True):
105109
"""Shared init function for all user administration scripts.
106110
The optional dynamic_db_path argument toggles dynamic user db path lookup
@@ -461,12 +465,12 @@ def _check_directories_unprovisioned(configuration, db_path):
461465

462466

463467
def _provision_directories(configuration):
464-
for config_attr in ('user_db_home', 'user_home', 'user_settings', 'user_cache', 'mrsl_files_dir', 'resource_pending'):
468+
for config_attr in _USERADM_CONFIG_DIR_KEYS:
465469
try:
466470
dir_to_create = getattr(configuration, config_attr)
467471
os.mkdir(dir_to_create)
468472
except OSError as oserr:
469-
if oserr.errno != errno.ENOENT: # FileNotFoundError
473+
if oserr.errno != errno.ENOENT: # FileNotFoundError
470474
raise
471475

472476

@@ -488,7 +492,7 @@ def create_user_in_db(configuration, db_path, client_id, user, now, authorized,
488492
try:
489493
flock = lock_user_db(db_path)
490494
except (IOError, OSError) as oserr:
491-
if oserr.errno != errno.ENOENT: # FileNotFoundError
495+
if oserr.errno != errno.ENOENT: # FileNotFoundError
492496
raise
493497

494498
if _check_directories_unprovisioned(configuration, db_path=db_path):

tests/test_mig_server_createuser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
from tests.support import MIG_BASE, TEST_OUTPUT_DIR, MigTestCase, testmain
3636

3737
from mig.server.createuser import main as createuser
38+
from mig.shared.useradm import _USERADM_CONFIG_DIR_KEYS
39+
3840

3941
class TestBooleans(MigTestCase):
4042
def before_each(self):
4143
configuration = self.configuration
4244
test_state_path = configuration.state_path
4345

44-
for config_key in ('user_db_home', 'user_home', 'user_settings', 'user_cache', 'mrsl_files_dir', 'resource_pending'):
46+
for config_key in _USERADM_CONFIG_DIR_KEYS:
4547
dir_path = getattr(configuration, config_key)[0:-1]
4648
try:
4749
shutil.rmtree(dir_path)
@@ -64,14 +66,16 @@ def test_user_db_is_created_and_user_is_added(self):
6466
"This is the create comment",
6567
"password"
6668
]
69+
print("") # acount for output generated by the logic
6770
createuser(args, TEST_OUTPUT_DIR, configuration=self.configuration)
6871

6972
# presence of user home
7073
path_kind = MigTestCase._absolute_path_kind(self.expected_user_db_home)
7174
self.assertEqual(path_kind, 'dir')
7275

7376
# presence of user db
74-
expected_user_db_file = os.path.join(self.expected_user_db_home, 'MiG-users.db')
77+
expected_user_db_file = os.path.join(
78+
self.expected_user_db_home, 'MiG-users.db')
7579
path_kind = MigTestCase._absolute_path_kind(expected_user_db_file)
7680
self.assertEqual(path_kind, 'file')
7781

0 commit comments

Comments
 (0)