<s> from awscli . compat import six <EOL> import mock <EOL> from botocore . model import DenormalizedStructureBuilder <EOL> from awscli . testutils import unittest <EOL> from awscli . customizations . generatecliskeleton import GenerateCliSkeletonArgument <EOL> class TestGenerateCliSkeleton ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . session = mock . Mock ( ) <EOL> self . service_operation = mock . Mock ( ) <EOL> self . input_shape = { <EOL> '<STR_LIT:A>' : { <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:B>' : { '<STR_LIT:type>' : '<STR_LIT:string>' } , <EOL> } <EOL> } <EOL> } <EOL> shape = DenormalizedStructureBuilder ( ) . with_members ( <EOL> self . input_shape ) . build_model ( ) <EOL> self . operation_model = mock . Mock ( input_shape = shape ) <EOL> self . argument = GenerateCliSkeletonArgument ( self . session , self . operation_model ) <EOL> self . ref_json_output = '<STR_LIT>' <EOL> def test_register_argument_action ( self ) : <EOL> register_args = self . session . register . call_args_list <EOL> self . assertEqual ( register_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( register_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> self . argument . generate_json_skeleton ) <EOL> def test_generate_json_skeleton ( self ) : <EOL> parsed_args = mock . Mock ( ) <EOL> parsed_args . generate_cli_skeleton = True <EOL> with mock . patch ( '<STR_LIT>' , six . StringIO ( ) ) as mock_stdout : <EOL> rc = self . argument . generate_json_skeleton ( <EOL> service_operation = self . service_operation , call_parameters = None , <EOL> parsed_args = parsed_args , parsed_globals = None <EOL> ) <EOL> self . assertEqual ( self . ref_json_output , mock_stdout . getvalue ( ) ) <EOL> self . assertEqual ( rc , <NUM_LIT:0> ) <EOL> def test_no_generate_json_skeleton ( self ) : <EOL> parsed_args = mock . Mock ( ) <EOL> parsed_args . generate_cli_skeleton = False <EOL> with mock . patch ( '<STR_LIT>' , six . StringIO ( ) ) as mock_stdout : <EOL> rc = self . argument . generate_json_skeleton ( <EOL> service_operation = self . service_operation , call_parameters = None , <EOL> parsed_args = parsed_args , parsed_globals = None <EOL> ) <EOL> self . assertEqual ( '<STR_LIT>' , mock_stdout . getvalue ( ) ) <EOL> self . assertEqual ( rc , None ) <EOL> def test_generate_json_skeleton_no_input_shape ( self ) : <EOL> parsed_args = mock . Mock ( ) <EOL> parsed_args . generate_cli_skeleton = True <EOL> self . argument = GenerateCliSkeletonArgument ( <EOL> self . session , mock . Mock ( input_shape = None ) ) <EOL> with mock . patch ( '<STR_LIT>' , six . StringIO ( ) ) as mock_stdout : <EOL> rc = self . argument . generate_json_skeleton ( <EOL> service_operation = self . service_operation , call_parameters = None , <EOL> parsed_args = parsed_args , parsed_globals = None <EOL> ) <EOL> self . assertEqual ( '<STR_LIT>' , mock_stdout . getvalue ( ) ) <EOL> self . assertEqual ( rc , <NUM_LIT:0> ) </s>
