Skip to content

Commit

Permalink
replace depecration mechanics from decorator to the one of VerdiComma…
Browse files Browse the repository at this point in the history
…nd; keep tests for deprecated command
  • Loading branch information
agoscinski committed Jun 6, 2024
1 parent 63ef0c4 commit 7605bb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion docs/source/reference/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ Below is a list with all available subcommands.
delete Delete one or more profiles.
list Display a list of all available profiles.
set-default Set a profile as the default profile.
setdefault Set a profile as the default profile.
setdefault (Deprecated) Set a profile as the default profile (use `verdi profile set-
default`).
setup Set up a new profile.
show Show details for a profile.
Expand Down
6 changes: 2 additions & 4 deletions src/aiida/cmdline/commands/cmd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from aiida.cmdline.params import arguments, options
from aiida.cmdline.params.options.commands import setup
from aiida.cmdline.utils import defaults, echo
from aiida.cmdline.utils.decorators import deprecated_command
from aiida.common import exceptions
from aiida.manage.configuration import Profile, create_profile, get_config

Expand Down Expand Up @@ -148,11 +147,10 @@ def profile_show(profile):
echo.echo_dictionary(config, fmt='yaml')


@verdi_profile.command('setdefault')
@deprecated_command('setdefault is deprecated, use set-default instead', version=3)
@verdi_profile.command('setdefault', deprecated='Please use `verdi profile set-default` instead.')
@arguments.PROFILE(required=True, default=None)
def profile_setdefault(profile):
"""Set a profile as the default profile."""
"""Set a profile as the default profile (use `verdi profile set-default`)."""
_profile_set_default(profile)

Check warning on line 154 in src/aiida/cmdline/commands/cmd_profile.py

View check run for this annotation

Codecov / codecov/patch

src/aiida/cmdline/commands/cmd_profile.py#L154

Added line #L154 was not covered by tests


Expand Down
10 changes: 8 additions & 2 deletions tests/cmdline/commands/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ def test_list(run_cli_command, mock_profiles):
assert profile_list[1] in result.output


def test_setdefault_deprecated(run_cli_command, mock_profiles):
def test_setdefault(run_cli_command, mock_profiles):
"""Test the ``verdi profile set_default`` command."""
profile_list = mock_profiles()
run_cli_command(cmd_profile.profile_setdefault, [profile_list[1]], use_subprocess=False)
result = run_cli_command(cmd_profile.profile_list, use_subprocess=False)
assert 'deprecated' in result.output

assert 'Report: configuration folder:' in result.output
assert f'* {profile_list[1]}' in result.output

# test if deprecation warning is printed
assert 'Deprecated:' in result.output
assert 'Deprecated:' in result.stderr


def test_set_default(run_cli_command, mock_profiles):
Expand Down

0 comments on commit 7605bb5

Please sign in to comment.