Skip to content

Commit

Permalink
IMPROVE: make label the default group list order (#5523)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramirezfranciscof authored May 16, 2022
1 parent 96a4a6b commit 1a6f492
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion aiida/cmdline/commands/cmd_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def group_show(group, raw, limit, uuid):
default=None,
help='Add a filter to show only groups for which the label contains STRING.'
)
@options.ORDER_BY(type=click.Choice(['id', 'label', 'ctime']), default='id')
@options.ORDER_BY(type=click.Choice(['id', 'label', 'ctime']), default='label')
@options.ORDER_DIRECTION()
@options.NODE(help='Show only the groups that contain the node.')
@with_dbenv()
Expand Down
7 changes: 3 additions & 4 deletions tests/cmdline/commands/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ def test_list_order(self):
options = []
result = self.cli_runner(cmd_group.group_list, options)
group_ordering = [l.split()[1] for l in result.output.split('\n')[3:] if l]
assert ['dummygroup1', 'dummygroup2', 'dummygroup3', 'dummygroup4', 'agroup'] == group_ordering
assert ['agroup', 'dummygroup1', 'dummygroup2', 'dummygroup3', 'dummygroup4'] == group_ordering

options = ['--order-by', 'label']
options = ['--order-by', 'id']
result = self.cli_runner(cmd_group.group_list, options)
group_ordering = [l.split()[1] for l in result.output.split('\n')[3:] if l]
assert ['agroup', 'dummygroup1', 'dummygroup2', 'dummygroup3', 'dummygroup4'] == group_ordering
assert ['dummygroup1', 'dummygroup2', 'dummygroup3', 'dummygroup4', 'agroup'] == group_ordering

options = ['--order-by', 'id', '--order-direction', 'desc']
result = self.cli_runner(cmd_group.group_list, options)

group_ordering = [l.split()[1] for l in result.output.split('\n')[3:] if l]
assert ['agroup', 'dummygroup4', 'dummygroup3', 'dummygroup2', 'dummygroup1'] == group_ordering

Expand Down

0 comments on commit 1a6f492

Please sign in to comment.