Skip to content

Commit 528452e

Browse files
committed
Allows all arguments/options with deprecated 'sl' command
1 parent 1667dbb commit 528452e

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

SoftLayer/CLI/deprecated.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
Handles usage of the deprecated command name, 'sl'.
55
:license: MIT, see LICENSE for more details.
66
"""
7+
from __future__ import print_function
78
import sys
89

9-
import click
1010

11-
12-
@click.command()
1311
def main():
1412
"""Main function for the deprecated 'sl' command."""
15-
click.echo("ERROR: Use the 'slcli' command instead.", err=True)
16-
click.echo("> slcli %s" % ' '.join(sys.argv[1:]), err=True)
13+
print("ERROR: Use the 'slcli' command instead.", file=sys.stderr)
14+
print("> slcli %s" % ' '.join(sys.argv[1:]), file=sys.stderr)
1715
exit(-1)

SoftLayer/tests/CLI/deprecated_tests.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@
44
55
:license: MIT, see LICENSE for more details.
66
"""
7-
import click
7+
import mock
88

99
from SoftLayer.CLI import deprecated
1010
from SoftLayer import testing
11+
from SoftLayer import utils
1112

1213

1314
class EnvironmentTests(testing.TestCase):
1415

1516
def test_main(self):
16-
runner = click.testing.CliRunner()
17-
result = runner.invoke(deprecated.main)
17+
with mock.patch('sys.stderr', new=utils.StringIO()) as fake_out:
18+
ex = self.assertRaises(SystemExit, deprecated.main)
19+
self.assertEqual(ex.code, -1)
1820

19-
self.assertEqual(result.exit_code, -1)
20-
self.assertIn("ERROR: Use the 'slcli' command instead.", result.output)
21+
self.assertIn("ERROR: Use the 'slcli' command instead.",
22+
fake_out.getvalue())
23+
24+
def test_with_args(self):
25+
26+
with mock.patch('sys.stderr', new=utils.StringIO()) as fake_out:
27+
with mock.patch('sys.argv', new=['sl', 'module', 'subcommand']):
28+
ex = self.assertRaises(SystemExit, deprecated.main)
29+
self.assertEqual(ex.code, -1)
30+
31+
self.assertIn("ERROR: Use the 'slcli' command instead.",
32+
fake_out.getvalue())

0 commit comments

Comments
 (0)