Skip to content

Commit 57262dc

Browse files
author
Juliya Smith
authored
Improv err (#215)
1 parent 5d6f8dc commit 57262dc

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/code42cli/cmds/devices.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def _deactivate_device(sdk, device_guid, change_device_name, purge_date):
7474
try:
7575
device = _change_device_activation(sdk, device_guid, "deactivate")
7676
except exceptions.Py42BadRequestError:
77-
raise Code42CLIError("The device {} is in legal hold.".format(device_guid))
77+
raise Code42CLIError(
78+
"The device with GUID '{}' is in legal hold.".format(device_guid)
79+
)
7880
if purge_date:
7981
_update_cold_storage_purge_date(sdk, device_guid, purge_date)
8082
if change_device_name and not device.data["name"].startswith("deactivated_"):
@@ -102,9 +104,13 @@ def _change_device_activation(sdk, device_guid, cmd_str):
102104
sdk.devices.deactivate(device_id)
103105
return device
104106
except exceptions.Py42NotFoundError:
105-
raise Code42CLIError("The device {} was not found.".format(device_guid))
107+
raise Code42CLIError(
108+
"The device with GUID '{}' was not found.".format(device_guid)
109+
)
106110
except exceptions.Py42ForbiddenError:
107-
raise Code42CLIError("Unable to {} {}.".format(cmd_str, device_guid))
111+
raise Code42CLIError(
112+
"Unable to {} the device with GUID '{}'.".format(cmd_str, device_guid)
113+
)
108114

109115

110116
def _verify_guid_type(device_guid):

tests/cmds/test_devices.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,10 @@ def test_deactivate_fails_if_device_does_not_exist(
432432
cli, ["devices", "deactivate", TEST_DEVICE_GUID], obj=cli_state
433433
)
434434
assert result.exit_code == 1
435-
assert "The device {} was not found.".format(TEST_DEVICE_GUID) in result.output
435+
assert (
436+
"The device with GUID '{}' was not found.".format(TEST_DEVICE_GUID)
437+
in result.output
438+
)
436439

437440

438441
def test_deactivate_fails_if_device_is_on_legal_hold(
@@ -442,7 +445,10 @@ def test_deactivate_fails_if_device_is_on_legal_hold(
442445
cli, ["devices", "deactivate", TEST_DEVICE_GUID], obj=cli_state
443446
)
444447
assert result.exit_code == 1
445-
assert "The device {} is in legal hold.".format(TEST_DEVICE_GUID) in result.output
448+
assert (
449+
"The device with GUID '{}' is in legal hold.".format(TEST_DEVICE_GUID)
450+
in result.output
451+
)
446452

447453

448454
def test_deactivate_fails_if_device_deactivation_forbidden(
@@ -452,7 +458,10 @@ def test_deactivate_fails_if_device_deactivation_forbidden(
452458
cli, ["devices", "deactivate", TEST_DEVICE_GUID], obj=cli_state
453459
)
454460
assert result.exit_code == 1
455-
assert "Unable to deactivate {}.".format(TEST_DEVICE_GUID) in result.output
461+
assert (
462+
"Unable to deactivate the device with GUID '{}'.".format(TEST_DEVICE_GUID)
463+
in result.output
464+
)
456465

457466

458467
def test_reactivate_reactivates_device(
@@ -469,7 +478,7 @@ def test_reactivate_fails_if_device_does_not_exist(
469478
cli, ["devices", "reactivate", TEST_DEVICE_GUID], obj=cli_state
470479
)
471480
assert result.exit_code == 1
472-
assert f"The device {TEST_DEVICE_GUID} was not found." in result.output
481+
assert f"The device with GUID '{TEST_DEVICE_GUID}' was not found." in result.output
473482

474483

475484
def test_reactivate_fails_if_device_reactivation_forbidden(
@@ -479,7 +488,10 @@ def test_reactivate_fails_if_device_reactivation_forbidden(
479488
cli, ["devices", "reactivate", TEST_DEVICE_GUID], obj=cli_state
480489
)
481490
assert result.exit_code == 1
482-
assert f"Unable to reactivate {TEST_DEVICE_GUID}." in result.output
491+
assert (
492+
f"Unable to reactivate the device with GUID '{TEST_DEVICE_GUID}'."
493+
in result.output
494+
)
483495

484496

485497
def test_show_prints_device_info(runner, cli_state, backupusage_success):

0 commit comments

Comments
 (0)