-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: Usability improvements for interactive
verdi setup
There were a number of ways that a user could break the command by providing incorrect input that was not caught by validation: * The following options are now required and can no longer incorrectly be skipped with `!`: `user_email`, `user_first_name`, `user_last_name` `user_institution`, `db_engine`, `db_backend`, `db_host`, `db_port` and the `repository_path`. * For a missing parameter in interactive mode the error now reads: Error: Institution has to be specified Instead of: Error: Missing parameter: institution which should be more intuitive * The message that a profile has successfully been created is now only displayed if the storage backend initialized successfully. Before, this was shown before storage initialization, which could then still fail, making the success message confusing.
- Loading branch information
Showing
6 changed files
with
34 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ def test_help(self): | |
self.cli_runner(cmd_setup.setup, ['--help']) | ||
self.cli_runner(cmd_setup.quicksetup, ['--help']) | ||
|
||
def test_quicksetup(self): | ||
def test_quicksetup(self, tmp_path): | ||
"""Test `verdi quicksetup`.""" | ||
profile_name = 'testing' | ||
user_email = '[email protected]' | ||
|
@@ -60,7 +60,8 @@ def test_quicksetup(self): | |
options = [ | ||
'--non-interactive', '--profile', profile_name, '--email', user_email, '--first-name', user_first_name, | ||
'--last-name', user_last_name, '--institution', user_institution, '--db-port', self.pg_test.dsn['port'], | ||
'--db-backend', self.storage_backend_name | ||
'--db-backend', self.storage_backend_name, '--repository', | ||
str(tmp_path) | ||
] | ||
|
||
self.cli_runner(cmd_setup.quicksetup, options, use_subprocess=False) | ||
|
@@ -83,7 +84,7 @@ def test_quicksetup(self): | |
backend = profile.storage_cls(profile) | ||
assert backend.get_global_variable('repository|uuid') == backend.get_repository().uuid | ||
|
||
def test_quicksetup_from_config_file(self): | ||
def test_quicksetup_from_config_file(self, tmp_path): | ||
"""Test `verdi quicksetup` from configuration file.""" | ||
with tempfile.NamedTemporaryFile('w') as handle: | ||
handle.write( | ||
|
@@ -94,12 +95,13 @@ def test_quicksetup_from_config_file(self): | |
institution: EPFL | ||
db_backend: {self.storage_backend_name} | ||
db_port: {self.pg_test.dsn['port']} | ||
email: [email protected]""" | ||
email: [email protected] | ||
repository: {tmp_path}""" | ||
) | ||
handle.flush() | ||
self.cli_runner(cmd_setup.quicksetup, ['--config', os.path.realpath(handle.name)], use_subprocess=False) | ||
|
||
def test_quicksetup_autofill_on_early_exit(self): | ||
def test_quicksetup_autofill_on_early_exit(self, tmp_path): | ||
"""Test `verdi quicksetup` stores user information even if command fails.""" | ||
config = configuration.get_config() | ||
assert config.get_option('autofill.user.email', scope=None) is None | ||
|
@@ -117,7 +119,8 @@ def test_quicksetup_autofill_on_early_exit(self): | |
options = [ | ||
'--non-interactive', '--profile', 'testing', '--email', user_email, '--first-name', user_first_name, | ||
'--last-name', user_last_name, '--institution', user_institution, '--db-port', | ||
self.pg_test.dsn['port'] + 100 | ||
self.pg_test.dsn['port'] + 100, '--repository', | ||
str(tmp_path) | ||
] | ||
|
||
self.cli_runner(cmd_setup.quicksetup, options, raises=True, use_subprocess=False) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters