Path: blob/develop/tests/unit/customizations/test_argrename.py
1567 views
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12from awscli.testutils import unittest13from awscli.customizations import argrename14from awscli.customizations import arguments1516from botocore import model171819class TestArgumenManipulations(unittest.TestCase):20def setUp(self):21self.argument_table = {}2223def test_can_rename_argument(self):24arg = arguments.CustomArgument('foo')25self.argument_table['foo'] = arg26handler = argrename.rename_arg('foo', 'bar')27handler(self.argument_table)2829self.assertIn('bar', self.argument_table)30self.assertNotIn('foo', self.argument_table)31self.assertEqual(arg.name, 'bar')3233def test_can_alias_an_argument(self):34arg = arguments.CustomArgument(35'foo', dest='foo',36argument_model=model.Shape('FooArg', {'type': 'string'}))37self.argument_table['foo'] = arg38handler = argrename.hidden_alias('foo', 'alias-name')3940handler(self.argument_table)4142self.assertIn('alias-name', self.argument_table)43self.assertIn('foo', self.argument_table)44self.assertEqual(self.argument_table['alias-name'].name, 'alias-name')454647