Beispiel #1
0
 def test_generate_all_commands(self):
     aws_commands = AwsCommands()
     commands, sub_commands, global_options, resource_options, \
         ec2_states = aws_commands.generate_all_commands()
     num_commands = 0
     num_sub_commands = 0
     num_global_options = 0
     num_resource_options = 0
     num_ec2_states = 0
     with open(AwsCommands.SOURCES_PATH) as f:
         for line in f:
             line = re.sub('\n', '', line)
             if AwsCommands.COMMANDS_HEADER in line:
                 num_commands = \
                     int(line.strip(AwsCommands.COMMANDS_HEADER))
             elif AwsCommands.SUB_COMMANDS_HEADER in line:
                 num_sub_commands = \
                     int(line.strip(AwsCommands.SUB_COMMANDS_HEADER))
             elif AwsCommands.GLOBAL_OPTIONS_HEADER in line:
                 num_global_options = \
                     int(line.strip(AwsCommands.GLOBAL_OPTIONS_HEADER))
             elif AwsCommands.RESOURCE_OPTIONS_HEADER in line:
                 num_resource_options = \
                     int(line.strip(AwsCommands.RESOURCE_OPTIONS_HEADER))
             elif AwsCommands.EC2_STATES_HEADER in line:
                 num_ec2_states = \
                     int(line.strip(AwsCommands.EC2_STATES_HEADER))
     assert len(commands) == num_commands
     assert len(sub_commands) == num_sub_commands
     assert len(global_options) == num_global_options
     assert len(resource_options) == num_resource_options
     assert len(ec2_states) == num_ec2_states
Beispiel #2
0
 def create_completer(self):
     # TODO: Fix duplicate creation of AwsCompleter, which is already
     # created by Saws init
     self.aws_commands = AwsCommands()
     self.all_commands = self.aws_commands.all_commands
     self.commands, self.sub_commands, self.global_options, \
         self.resource_options = self.all_commands
     return AwsCompleter(awscli_completer, self.all_commands,
                         self.saws.config, self.saws.config_obj,
                         self.saws.logger)
Beispiel #3
0
 def create_completer(self):
     self.aws_commands = AwsCommands()
     self.commands, self.sub_commands, self.global_options, \
         self.resource_options, self.ec2_states = \
         self.aws_commands.generate_all_commands()
     return AwsCompleter(awscli_completer,
                         self.saws.commands,
                         self.saws.config_obj,
                         self.saws.logger,
                         self.ec2_states)
Beispiel #4
0
 def test_all_commands(self):
     aws_commands = AwsCommands()
     command_lists = aws_commands.all_commands
     num_results_list = [None] * \
         aws_commands.CommandType.NUM_TYPES.value
     with open(AwsCommands.DATA_PATH) as f:
         for line in f:
             line = re.sub('\n', '', line)
             for command_header in aws_commands.headers:
                 if command_header in line:
                     command_type_value = aws_commands \
                         .header_to_type_map[command_header].value
                     num_results_list[command_type_value] = \
                         int(line.strip(command_header))
                     continue
     for index, num_results in enumerate(num_results_list):
         assert (len(command_lists[index]) == num_results)