def test_create_2_json_file_action(self):
        p1 = computation_job_param.ComputationJobParam("mypar1",
                                                       "application/json",
                                                       "par 1",
                                                       "par descr 1",
                                                       max_occurencies=2)
        inputs = computation_job_inputs.ComputationJobInputs()
        inputs.add_input(p1)

        actions = computational_job_input_actions.ComputationalJobInputActions(
        )
        a1 = computational_job_input_action_create_json_file. \
            ComputationalJobInputActionCreateJSONFile("mypar1",
                                                      path.path("./json_out_${json_path_expr}.json"),
                                                      "['Asset']['id']",
                                                      path.path("./src/wpsremote/xmpp_data/test/asset_schema.json"))
        actions.add_actions(a1)

        inputs.set_values({
            "mypar1": [
                TestComputationJobInputs.json_text1,
                TestComputationJobInputs.json_text2
            ]
        })
        actions.execute(inputs)

        self.assertTrue(a1.exists())
    def test_cmd_line_action(self):
        inputs = computation_job_inputs.ComputationJobInputs()
        inputs.add_input(
            computation_job_param.ComputationJobParam("mypar1", "int", "par 1",
                                                      "par descr 1"))

        actions = computational_job_input_actions.ComputationalJobInputActions(
        )
        actions.add_actions(
            computational_job_input_action_cmd_param.
            ComputationalJobInputActionCmdParam("mypar1", "--name=value"))
        inputs.set_values({"mypar1": "1"})
        actions.execute(inputs)

        self.assertEquals(actions.get_cmd_line(), "--mypar1=1")
    def test_cmd_line_action_2_values(self):
        p1 = computation_job_param.ComputationJobParam("mypar1", "int",
                                                       "par 1", "par descr 1")
        p2 = computation_job_param.ComputationJobParam("mypar2", "string",
                                                       "par 2", "par descr 2")
        inputs = computation_job_inputs.ComputationJobInputs()
        inputs.add_input([p1, p2])

        actions = computational_job_input_actions.ComputationalJobInputActions(
        )
        actions.add_actions(
            computational_job_input_action_cmd_param.
            ComputationalJobInputActionCmdParam("mypar1", "--name=value"))
        actions.add_actions(
            computational_job_input_action_cmd_param.
            ComputationalJobInputActionCmdParam("mypar2", "--name=value"))

        inputs.set_values({"mypar1": "1", "mypar2": "abc"})
        actions.execute(inputs)

        self.assertEquals(actions.get_cmd_line(), "--mypar1=1 --mypar2=abc")
    def test_create_json_file_action(self):
        os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__),
                                              '..')))
        p1 = computation_job_param.ComputationJobParam("mypar1",
                                                       "application/json",
                                                       "par 1", "par descr 1")
        inputs = computation_job_inputs.ComputationJobInputs()
        inputs.add_input(p1)

        actions = computational_job_input_actions.ComputationalJobInputActions(
        )
        a1 = computational_job_input_action_create_json_file. \
            ComputationalJobInputActionCreateJSONFile("mypar1",
                                                      path.path("./json_out_${json_path_expr}.json"),
                                                      "['Asset']['id']",
                                                      path.path("./src/wpsremote/xmpp_data/test/asset_schema.json"))
        actions.add_actions(a1)

        inputs.set_values({"mypar1": TestComputationJobInputs.json_text1})
        actions.execute(inputs)

        self.assertTrue(a1.exists())