コード例 #1
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_empty_requirements(self):
     blueprint = 'blueprint_without_plugins'
     blueprint_path = '{0}/local/{1}.yaml'.format(
         test_cli_command.BLUEPRINTS_DIR, blueprint)
     cli_runner.run_cli(
         'aria init --install-plugins -p {0} -b {1}'
         .format(blueprint_path, blueprint))
コード例 #2
0
    def _assert_ex(self,
                   cli_cmd,
                   err_str_segment,
                   possible_solutions=None):

        def _assert():
            self.assertIn(err_str_segment, str(ex))
            if possible_solutions:
                if hasattr(ex, 'possible_solutions'):
                    self.assertEqual(ex.possible_solutions,
                                     possible_solutions)
                else:
                    self.fail('Exception should have '
                              'declared possible solutions')

        try:
            cli_runner.run_cli(cli_cmd)
            self.fail('Expected error {0} was not raised for command {1}'
                      .format(err_str_segment, cli_cmd))
        except (exceptions.AriaError,
                SystemExit,
                exceptions.AriaValidationError,
                ValueError,
                IOError,
                ImportError,
                Exception) as ex:
            _assert()
コード例 #3
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_execute_with_params_allow_custom_true(self):
     b_id = self._local_init()
     self._local_execute(b_id,
                         parameters={
                             'custom_param':
                                 'custom_param_value'},
                         allow_custom=True)
     cli_runner.run_cli(
         'aria outputs -b {0}'.format(b_id))
コード例 #4
0
    def test_install_plugins(self):

        blueprint_path = '{0}/local/blueprint_with_plugins.yaml'\
            .format(BLUEPRINTS_DIR)
        try:
            cli_runner.run_cli(
                'aria install-plugins -p {0}'.format(blueprint_path))
        except CommandExecutionException as e:
            # Expected pip install to start
            self.assertIn('pip install -r /tmp/requirements_', e.message)
コード例 #5
0
 def assert_method_called(self,
                          cli_command,
                          module,
                          function_name,
                          kwargs):
     with patch.object(module, function_name) as mock:
         try:
             cli_runner.run_cli(cli_command)
         except BaseException as e:
             self.logger.info(e.message)
         mock.assert_called_with(**kwargs)
コード例 #6
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
    def test_install_plugins(self):

        blueprint_path = '{0}/local/blueprint_with_plugins.yaml'\
            .format(BLUEPRINTS_DIR)
        try:
            cli_runner.run_cli('aria install-plugins -p {0}'
                               .format(blueprint_path))
        except CommandExecutionException as e:
            # Expected pip install to start
            self.assertIn('pip install -r /tmp/requirements_',
                          e.message)
コード例 #7
0
    def test_all_commands(self):

        """
        Run all commands.
        """

        all_commands = get_all_commands()
        for command in all_commands:
            possible_commands = get_combinations(command)
            for possible_command in possible_commands:
                cli_runner.run_cli("aria {0}".format(possible_command))
コード例 #8
0
ファイル: test_local.py プロジェクト: denismakogon/aria-cli
    def test_install_plugins(self):

        blueprint_path = ('{0}/local/blueprint_with_plugins.yaml'.
                          format(test_cli_command.BLUEPRINTS_DIR))
        try:
            cli_runner.run_cli('aria install-plugins -p {0}'
                               .format(blueprint_path))
        except futures.aria_aside_exceptions.CommandExecutionException as e:
            # Expected pip install to start
            self.assertIn('pip install -r ',
                          e.message)
コード例 #9
0
    def test_all_commands_verbose(self):

        """
        Run all commands with 'verbosity' flags.
        """

        all_commands = get_all_commands()
        for command in all_commands:
            possible_commands = get_combinations(command)
            for possible_command in possible_commands:
                cli_runner.run_cli("aria {0} -v".format(possible_command))
                cli_runner.run_cli("aria {0} --verbose".format(possible_command))
コード例 #10
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_install_agent(self):
     blueprint_path = '{0}/local/install-agent-blueprint.yaml' \
         .format(BLUEPRINTS_DIR)
     try:
         cli_runner.run_cli('aria init -p {0}'.format(blueprint_path))
         self.fail('ValueError was expected')
     except ValueError as e:
         self.assertIn("'install_agent': true is not supported "
                       "(it is True by default) "
                       "when executing local workflows. "
                       "The 'install_agent' property must be set to false "
                       "for each node of type {0}.".format(HOST_TYPE),
                       e.message)
コード例 #11
0
 def test_install_agent(self):
     blueprint_path = '{0}/local/install-agent-blueprint.yaml' \
         .format(BLUEPRINTS_DIR)
     try:
         cli_runner.run_cli('aria init -p {0}'.format(blueprint_path))
         self.fail('ValueError was expected')
     except ValueError as e:
         self.assertIn(
             "'install_agent': true is not supported "
             "(it is True by default) "
             "when executing local workflows. "
             "The 'install_agent' property must be set to false "
             "for each node of type {0}.".format(HOST_TYPE), e.message)
コード例 #12
0
    def _local_init(self,
                    inputs=None,
                    blueprint='blueprint',
                    install_plugins=False):

        blueprint_path = '{0}/local/{1}.yaml'.format(BLUEPRINTS_DIR, blueprint)
        flags = '--install-plugins' if install_plugins else ''
        command = 'aria init {0} -p {1}'.format(flags, blueprint_path)
        if inputs:
            inputs_path = os.path.join(TEST_WORK_DIR, 'temp_inputs.json')
            with open(inputs_path, 'w') as f:
                f.write(json.dumps(inputs))
            command = '{0} -i {1}'.format(command, inputs_path)
        cli_runner.run_cli(command)
コード例 #13
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
    def _local_init(self,
                    inputs=None,
                    blueprint='blueprint',
                    install_plugins=False):

        blueprint_path = '{0}/local/{1}.yaml'.format(BLUEPRINTS_DIR,
                                                     blueprint)
        flags = '--install-plugins' if install_plugins else ''
        command = 'aria init {0} -p {1}'.format(flags,
                                                blueprint_path)
        if inputs:
            inputs_path = os.path.join(TEST_WORK_DIR,
                                       'temp_inputs.json')
            with open(inputs_path, 'w') as f:
                f.write(json.dumps(inputs))
            command = '{0} -i {1}'.format(command, inputs_path)
        cli_runner.run_cli(command)
コード例 #14
0
    def test_create_requirements(self):

        from aria_cli.tests.resources.blueprints import local

        expected_requirements = {
            'http://localhost/plugin.zip',
            os.path.join(os.path.dirname(local.__file__), 'plugins',
                         'local_plugin'), 'http://localhost/host_plugin.zip'
        }
        requirements_file_path = os.path.join(TEST_WORK_DIR,
                                              'requirements.txt')

        cli_runner.run_cli(
            'aria create-requirements -p '
            '{0}/local/blueprint_with_plugins.yaml -o {1}'.format(
                BLUEPRINTS_DIR, requirements_file_path))

        with open(requirements_file_path, 'r') as f:
            actual_requirements = set(f.read().split())
            self.assertEqual(actual_requirements, expected_requirements)
コード例 #15
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def _local_init(self,
                 inputs=None,
                 blueprint='blueprint',
                 install_plugins=False,
                 custom_blueprint_id=None):
     b_id = (blueprint if not custom_blueprint_id
             else custom_blueprint_id)
     blueprint_path = '{0}/local/{1}.yaml'.format(
         test_cli_command.BLUEPRINTS_DIR, blueprint)
     flags = '--install-plugins' if install_plugins else ''
     command = 'aria init {0} -b {2} -p {1}'.format(
         flags, blueprint_path, b_id)
     if inputs:
         inputs_path = os.path.join(test_cli_command.TEST_WORK_DIR,
                                    'temp_inputs.json')
         with open(inputs_path, 'w') as f:
             f.write(json.dumps(inputs))
         command = '{0} -i {1}'.format(command, inputs_path)
     cli_runner.run_cli(command)
     return b_id
コード例 #16
0
    def _assert_ex(self,
                   cli_cmd,
                   err_str_segment,
                   possible_solutions=None):

        def _assert():
            self.assertIn(err_str_segment, str(ex))
            if possible_solutions:
                if hasattr(ex, 'possible_solutions'):
                    self.assertEqual(ex.possible_solutions,
                                     possible_solutions)
                else:
                    self.fail('Exception should have '
                              'declared possible solutions')

        try:
            cli_runner.run_cli(cli_cmd)
            self.fail('Expected error {0} was not raised for command {1}'
                      .format(err_str_segment, cli_cmd))
        except SystemExit, ex:
            _assert()
コード例 #17
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
    def test_create_requirements(self):

        from aria_cli.tests.resources.blueprints import local

        expected_requirements = {
            'http://localhost/plugin.zip',
            os.path.join(
                os.path.dirname(local.__file__),
                'plugins',
                'local_plugin'),
            'http://localhost/host_plugin.zip'}
        requirements_file_path = os.path.join(TEST_WORK_DIR,
                                              'requirements.txt')

        cli_runner.run_cli('aria create-requirements -p '
                           '{0}/local/blueprint_with_plugins.yaml -o {1}'
                           .format(BLUEPRINTS_DIR, requirements_file_path))

        with open(requirements_file_path, 'r') as f:
            actual_requirements = set(f.read().split())
            self.assertEqual(actual_requirements, expected_requirements)
コード例 #18
0
    def test_create_requirements_no_output(self):

        from aria_cli.tests.resources.blueprints import local

        expected_requirements = {
            'http://localhost/plugin.zip',
            os.path.join(os.path.dirname(local.__file__), 'plugins',
                         'local_plugin'), 'http://localhost/host_plugin.zip'
        }
        output = cli_runner.run_cli(
            'aria create-requirements -p '
            '{0}/local/blueprint_with_plugins.yaml'.format(BLUEPRINTS_DIR))
        for requirement in expected_requirements:
            self.assertIn(requirement, output)
コード例 #19
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
    def test_create_requirements_no_output(self):

        from aria_cli.tests.resources.blueprints import local

        expected_requirements = {
            'http://localhost/plugin.zip',
            os.path.join(
                os.path.dirname(local.__file__),
                'plugins',
                'local_plugin'),
            'http://localhost/host_plugin.zip'}
        output = cli_runner.run_cli(
            'aria create-requirements -p '
            '{0}/local/blueprint_with_plugins.yaml'
            .format(BLUEPRINTS_DIR))
        for requirement in expected_requirements:
            self.assertIn(requirement, output)
コード例 #20
0
 def _local_execute(self,
                    parameters=None,
                    allow_custom=None,
                    workflow_name='run_test_op_on_nodes'):
     if parameters:
         parameters_path = os.path.join(TEST_WORK_DIR,
                                        'temp_parameters.json')
         with open(parameters_path, 'w') as f:
             f.write(json.dumps(parameters))
         command = 'aria execute -w {0} -p {1}'\
                   .format(workflow_name,
                           parameters_path)
         if allow_custom is True:
             cli_runner.run_cli(
                 '{0} --allow-custom-parameters'.format(command))
         elif allow_custom is False:
             self._assert_ex(command, 'does not have the following')
         else:
             cli_runner.run_cli(command)
     else:
         cli_runner.run_cli('aria execute -w {0}'.format(workflow_name))
コード例 #21
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def _local_execute(self, parameters=None,
                    allow_custom=None,
                    workflow_name='run_test_op_on_nodes'):
     if parameters:
         parameters_path = os.path.join(TEST_WORK_DIR,
                                        'temp_parameters.json')
         with open(parameters_path, 'w') as f:
             f.write(json.dumps(parameters))
         command = 'aria execute -w {0} -p {1}'\
                   .format(workflow_name,
                           parameters_path)
         if allow_custom is True:
             cli_runner.run_cli('{0} --allow-custom-parameters'
                                .format(command))
         elif allow_custom is False:
             self._assert_ex(command, 'does not have the following')
         else:
             cli_runner.run_cli(command)
     else:
         cli_runner.run_cli('aria execute -w {0}'
                            .format(workflow_name))
コード例 #22
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_local_init(self):
     self._local_init()
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"param": null', output)
     self.assertIn('"custom_param": null', output)
     self.assertIn('"input1": "default_input1"', output)
コード例 #23
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_instances_with_existing_node_id(self):
     b_id = self._local_init()
     self._local_execute(b_id)
     cli_runner.run_cli(
         'aria instances -b {0} --node-id node'.format(b_id))
コード例 #24
0
 def test_local_instances(self):
     self._local_init()
     self._local_execute()
     output = cli_runner.run_cli('aria instances')
     self.assertIn('"node_id": "node"', output)
コード例 #25
0
 def test_local_instances_with_existing_node_id(self):
     self._local_init()
     self._local_execute()
     output = cli_runner.run_cli('aria instances --node-id node')
     self.assertIn('"node_id": "node"', output)
コード例 #26
0
 def test_empty_requirements(self):
     blueprint = 'blueprint_without_plugins'
     blueprint_path = '{0}/local/{1}.yaml'.format(BLUEPRINTS_DIR, blueprint)
     cli_runner.run_cli(
         'aria init --install-plugins -p {0}'.format(blueprint_path))
コード例 #27
0
 def test_local_execute_with_params_allow_custom_true(self):
     self._local_init()
     self._local_execute(parameters={'custom_param': 'custom_param_value'},
                         allow_custom=True)
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"custom_param": "custom_param_value"', output)
コード例 #28
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_instances(self):
     b_id = self._local_init()
     self._local_execute(b_id)
     cli_runner.run_cli(
         'aria instances -b {0}'.format(b_id))
コード例 #29
0
 def test_install_plugins_missing_windows_agent_installer(self):
     blueprint_path = '{0}/local/windows_installers_blueprint.yaml'\
         .format(BLUEPRINTS_DIR)
     cli_runner.run_cli('aria init -p {0}'.format(blueprint_path))
コード例 #30
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_local_execute(self):
     self._local_init()
     self._local_execute()
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"param": "default_param"', output)
コード例 #31
0
 def _test_all_combinations(self, command_path):
     possible_commands = get_combinations(command_path)
     for command in possible_commands:
         cli_runner.run_cli("aria {0}".format(command))
コード例 #32
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_install_plugins_missing_windows_agent_installer(self):
     blueprint_path = '{0}/local/windows_installers_blueprint.yaml'\
         .format(BLUEPRINTS_DIR)
     cli_runner.run_cli('aria init -p {0}'.format(blueprint_path))
コード例 #33
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_execute_with_params(self):
     b_id = self._local_init()
     self._local_execute(b_id,
                         parameters={'param': 'new_param'})
     cli_runner.run_cli(
         'aria outputs -b {0}'.format(b_id))
コード例 #34
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_local_execute_with_params_allow_custom_true(self):
     self._local_init()
     self._local_execute(parameters={'custom_param': 'custom_param_value'},
                         allow_custom=True)
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"custom_param": "custom_param_value"', output)
コード例 #35
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_local_instances_with_existing_node_id(self):
     self._local_init()
     self._local_execute()
     output = cli_runner.run_cli('aria instances --node-id node')
     self.assertIn('"node_id": "node"', output)
コード例 #36
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_create_requirements_no_output(self):
     cli_runner.run_cli(
         'aria create-requirements -p '
         '{0}/local/blueprint_with_plugins.yaml'
         .format(test_cli_command.BLUEPRINTS_DIR))
コード例 #37
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_local_instances(self):
     self._local_init()
     self._local_execute()
     output = cli_runner.run_cli('aria instances')
     self.assertIn('"node_id": "node"', output)
コード例 #38
0
 def test_local_execute_with_params(self):
     self._local_init()
     self._local_execute(parameters={'param': 'new_param'})
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"param": "new_param"', output)
コード例 #39
0
ファイル: test_local.py プロジェクト: linzhishui/aria-cli
 def test_local_init_with_inputs(self):
     self._local_init(inputs={'input1': 'new_input1'})
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"input1": "new_input1"', output)
コード例 #40
0
 def test_local_init_with_inputs(self):
     self._local_init(inputs={'input1': 'new_input1'})
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"input1": "new_input1"', output)
コード例 #41
0
 def test_local_init(self):
     self._local_init()
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"param": null', output)
     self.assertIn('"custom_param": null', output)
     self.assertIn('"input1": "default_input1"', output)
コード例 #42
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_init(self):
     b_id = self._local_init()
     cli_runner.run_cli(
         'aria outputs -b {0}'.format(b_id))
コード例 #43
0
 def test_local_execute(self):
     self._local_init()
     self._local_execute()
     output = cli_runner.run_cli('aria outputs')
     self.assertIn('"param": "default_param"', output)
コード例 #44
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_init_with_inputs(self):
     blueprint_id = self._local_init(
         inputs={'input1': 'new_input1'})
     cli_runner.run_cli(
         'aria outputs -b {0}'.format(blueprint_id))
コード例 #45
0
 def test_blueprint_validate(self):
     cli_runner.run_cli('aria validate '
                        '-p {0}/helloworld/blueprint.yaml'
                        .format(BLUEPRINTS_DIR))
コード例 #46
0
ファイル: test_local.py プロジェクト: rbramwell/aria-cli
 def test_local_execute(self):
     blueprint_id = self._local_init()
     self._local_execute(blueprint_id)
     cli_runner.run_cli(
         'aria outputs -b {0}'.format(blueprint_id))