Skip to content

Commit

Permalink
Undocument deprecated operations
Browse files Browse the repository at this point in the history
  • Loading branch information
joguSD committed Oct 13, 2017
1 parent 2b75262 commit c016291
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/enhancement-documentation-54107.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "enhancement",
"category": "documentation",
"description": "Deprecated operations will no longer appear in help documentation or be suggested in autocompletion results."
}
2 changes: 2 additions & 0 deletions awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ def __init__(self, name, parent_name, operation_caller,
self._lineage = [self]
self._operation_model = operation_model
self._session = session
if operation_model.deprecated:
self._UNDOCUMENTED = True

@property
def name(self):
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/docs/test_help_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ def test_shorthand_flattens_list_of_single_member_structures(self):
self.driver.main(['elb', 'remove-tags', 'help'])
self.assert_contains("--tags Key1 Key2 Key3")

def test_deprecated_operations_not_documented(self):
self.driver.main(['s3api', 'help'])
self.assert_not_contains('get-bucket-lifecycle\n')
self.assert_not_contains('put-bucket-lifecycle\n')
self.assert_not_contains('get-bucket-notification\n')
self.assert_not_contains('put-bucket-notification\n')


class TestRemoveDeprecatedCommands(BaseAWSHelpOutputTest):
def assert_command_does_not_exist(self, service, command):
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/test_clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,10 @@ def test_help_event_class(self):
class TestServiceOperation(unittest.TestCase):
def setUp(self):
self.name = 'foo'
self.cmd = ServiceOperation(self.name, None, None, None, None)
operation = mock.Mock(spec=botocore.model.OperationModel)
operation.deprecated = False
self.mock_operation = operation
self.cmd = ServiceOperation(self.name, None, None, operation, None)

def test_name(self):
self.assertEqual(self.cmd.name, self.name)
Expand All @@ -889,6 +892,12 @@ def test_lineage(self):
def test_lineage_names(self):
self.assertEqual(self.cmd.lineage_names, ['foo'])

def test_deprecated_operation(self):
self.mock_operation.deprecated = True
cmd = ServiceOperation(self.name, None, None, self.mock_operation,
None)
self.assertTrue(getattr(cmd, '_UNDOCUMENTED'))


if __name__ == '__main__':
unittest.main()
6 changes: 5 additions & 1 deletion tests/unit/test_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import mock

from botocore.compat import OrderedDict
from botocore.model import OperationModel
from awscli.clidriver import (
CLIDriver, ServiceCommand, ServiceOperation, CLICommand)
from awscli.arguments import BaseCLIArgument, CustomArgument
Expand Down Expand Up @@ -378,7 +379,10 @@ def _create_service_command(self, name, command):
def _create_operation_command(self, name, command):
argument_table = self.create_argument_table(
command.get('arguments', []))
operation = ServiceOperation(name, 'parent', None, {}, None)
mock_operation = mock.Mock(spec=OperationModel)
mock_operation.deprecated = False
operation = ServiceOperation(name, 'parent', None, mock_operation,
None)
operation._arg_table = argument_table
return operation

Expand Down

0 comments on commit c016291

Please sign in to comment.