Skip to content

Commit 06e95c0

Browse files
author
Brian Flores
committed
fix observations, add unit test and update error message
1 parent 9a9b57a commit 06e95c0

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

SoftLayer/CLI/user/remove_access.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
89

910

1011
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
@@ -24,20 +25,20 @@ def cli(env, identifier, hardware, virtual, dedicated):
2425
if hardware:
2526
result = mgr.remove_hardware_access(identifier, hardware)
2627
if result:
27-
click.secho("Remove to access to hardware: %s" % hardware, fg='green')
28+
click.secho(f"Removed access to hardware: {hardware}.", fg='green')
2829

2930
if virtual:
3031
result = mgr.remove_virtual_access(identifier, virtual)
3132
if result:
32-
click.secho("Remove to access to virtual guest: %s" % virtual, fg='green')
33+
click.secho(f"Removed access to virtual guest: {virtual}", fg='green')
3334

3435
if dedicated:
3536
result = mgr.remove_dedicated_access(identifier, dedicated)
3637
if result:
37-
click.secho("Remove to access to dedicated host: %s" % dedicated, fg='green')
38+
click.secho(f"Removed access to dedicated host: {dedicated}", fg='green')
3839

3940
if not result:
40-
raise SoftLayer.exceptions.SoftLayerError('You need argument a hardware, virtual or dedicated identifier.\n'
41-
'E.g slcli user remove-access 123456 --hardware 91803794\n'
42-
' slcli user remove-access 123456 --dedicated 91803793\n'
43-
' slcli user remove-access 123456 --virtual 91803792')
41+
raise exceptions.CLIAbort('A device option is required.\n'
42+
'E.g slcli user remove-access 123456 --hardware 91803794\n'
43+
' slcli user remove-access 123456 --dedicated 91803793\n'
44+
' slcli user remove-access 123456 --virtual 91803792')

tests/CLI/modules/user_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,8 @@ def test_remove_access_virtual(self):
356356
def test_remove_access_dedicated(self):
357357
result = self.run_command(['user', 'remove-access', '123456', '--dedicated', '369852'])
358358
self.assert_no_fail(result)
359+
360+
def test_remove_without_device(self):
361+
result = self.run_command(['user', 'remove-access', '123456'])
362+
self.assertEqual(2, result.exit_code)
363+
self.assertIn('A device option is required.', result.exception.message)

0 commit comments

Comments
 (0)