Skip to content

Commit

Permalink
feat: add confirmation to migrate command
Browse files Browse the repository at this point in the history
it operates on a potentially large number of groups, so this adds a
layer of protection against mistakes
  • Loading branch information
angela-tran committed Apr 5, 2024
1 parent 9646562 commit 1c94d66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion littlepay/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ def _maincmd(name, help):
groups_link = _subcmd(groups_commands, "link", help="Link one or more concession groups to a product")
groups_link.add_argument("product_id", help="The ID of the product to link to")

_subcmd(groups_commands, "migrate", help="Migrate a group from the old Customer Group format to the current format")
groups_migrate = _subcmd(
groups_commands, "migrate", help="Migrate a group from the old Customer Group format to the current format"
)
groups_migrate.add_argument(
"--force", action="store_true", default=False, help="Don't ask for confirmation before migration"
)

groups_products = _subcmd(groups_commands, "products", help="List products for one or more concession groups")
groups_products.add_argument(
Expand Down
10 changes: 10 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ def test_main_groups_migrate(mock_commands_groups):
assert call_args.group_command == "migrate"


def test_main_groups_migrate_force(mock_commands_groups):
result = main(argv=["groups", "migrate", "--force"])

assert result == RESULT_SUCCESS
mock_commands_groups.assert_called_once()
call_args = mock_commands_groups.call_args.args[0]
assert call_args.group_command == "migrate"
assert call_args.force is True


def test_main_groups_products(mock_commands_groups):
result = main(argv=["groups", "products"])

Expand Down

0 comments on commit 1c94d66

Please sign in to comment.