Beispiel #1
0
    def setUpTestData(cls):
        """
        setUpClass: this setup is made once for several tests_ methods

        operational database is not impacted by the Django unittests
        """
        # init logger with CommonsUnittest service
        cls.init_logger()

        cls.arg_one = Argument("angle", "angle (rad)", ProfileItem.DIR.INPUT,
                               0)
        cls.res_one = Argument("result", "cos(angle)", ProfileItem.DIR.OUTPUT,
                               0)
        cls.res_two = Argument("result", "sin(angle)", ProfileItem.DIR.OUTPUT,
                               0)
        cls.res_three = Argument("result", "tan(angle)",
                                 ProfileItem.DIR.OUTPUT, 0)

        cls.my_cosinus = Implementation(
            "TU ORM Python Standard cosinus", "Python cosinus from math::cos",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::cos", [cls.arg_one], [cls.res_one])

        cls.my_sinus = Implementation(
            "TU ORM Python Standard sinus", "Python sinus from math::sin",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::sin", [cls.arg_one], [cls.res_two])

        cls.my_tan = Implementation(
            "TU ORM Python Standard tan", "Python tan from math::tan",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::tan", [cls.arg_one], [cls.res_three])
Beispiel #2
0
    def build_business(self):
        """
        Build the business formatted Implementation based on the current ORM data
        :return: the business instance Implementation mapping self instance
        """
        biz_inputs = self.__build_business_profile(self.input_desc_items)

        biz_outputs = self.__build_business_profile(self.output_desc_items)

        biz_algo = None
        if self.algo:
            biz_algo = self.algo.build_business()

        biz_impl = Implementation(name=self.name,
                                  description=self.desc,
                                  execution_plugin=self.execution_plugin,
                                  library_address=self.library_address,
                                  input_profile=biz_inputs,
                                  output_profile=biz_outputs,
                                  db_id=self.id,
                                  label=self.label,
                                  visibility=self.visibility)

        biz_impl.algo = biz_algo

        return biz_impl
Beispiel #3
0
    def test_seq3_read():
        """
        Tests the read of Algorithm execution status
        """
        # even if unused: create stub data for Implementation
        my_impl_fake = Implementation(name="TU Fake Impl", description="TU fake",
                                      execution_plugin="TU fake",
                                      library_address="TU Fake",
                                      input_profile=None,
                                      output_profile=None,
                                      db_id=None)

        # even if unused: create stub data for CustomizedAlgo
        my_custom_algo_fake = CustomizedAlgo(arg_implementation=my_impl_fake, custom_params=None)

        current_date = time.time()
        LOGGER.info("Current date %s", current_date)
        my_exec_algo = ExecutableAlgo(
            custom_algo=my_custom_algo_fake, dict_data_sources={}, dict_data_receivers={}, arg_process_id=None)

        my_exec_algo.trigger_start_execution_date()
        my_exec_algo.trigger_end_execution_date()
        my_exec_algo.state = EnumState.ALGO_OK

        # ignore unsaved data here : we test the update in database
        my_exec_algo_created = ExecutableAlgoDao.create(my_exec_algo, merge_with_unsaved_data=False)
        string_algo_before = my_exec_algo_created.as_detailed_string()
        LOGGER.info("DB Before read  : %s", string_algo_before)

        my_exec_algo_read = ExecutableAlgoDao.find_from_key(my_exec_algo_created.process_id)
        string_db_read = my_exec_algo_read.as_detailed_string()

        LOGGER.info("DB after read   : %s", string_db_read)
    def test_init(self):
        """
        Tests the init method override
        """
        imp = Implementation('Name_of_my_implementation',
                             'description of my implementation',
                             'Execution_plugin_name', 'library/address/')

        self.assertEquals(imp.input_profile, [])
        self.assertEquals(imp.output_profile, [])
    def setUpTestData(cls):
        """
        setUpClass: this setup is made once for several tests_ methods

        operational database is not impacted by the Django unittests
        """
        cls.init_tu()
        arg_one = Argument("angle", "angle (rad)", ProfileItem.DIR.INPUT, 0)
        res_one = Argument("result", "cos(angle)", ProfileItem.DIR.OUTPUT, 0)

        cls.my_cosinus = Implementation(
            "TU WS Python Standard cosinus", "Python cosinus from math::cos",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::cos", [arg_one], [res_one])
Beispiel #6
0
    def test_seq1_create(self):
        """
        Tests the creation of Algorithm execution
        """
        # even if unused: create stub data for Implementation
        my_impl_fake = Implementation(name="TU Fake Impl", description="TU fake",
                                      execution_plugin="TU fake",
                                      library_address="TU Fake",
                                      input_profile=None,
                                      output_profile=None,
                                      db_id=None)

        # even if unused: create stub data for CustomizedAlgo
        my_custom_algo_fake = CustomizedAlgo(arg_implementation=my_impl_fake, custom_params=None)

        current_date = time.time()
        LOGGER.info("Current date %s", current_date)
        my_exec_algo = ExecutableAlgo(
            custom_algo=my_custom_algo_fake, dict_data_sources={}, dict_data_receivers={}, arg_process_id=None)

        string_algo_before = my_exec_algo.as_detailed_string()

        LOGGER.info("creation date= %s", my_exec_algo.creation_date)

        nb_init = ExecutableAlgoDao.objects.count()
        LOGGER.info("After test_seq1_create: ImplementationDao count = %s", nb_init)

        my_exec_algo_created = ExecutableAlgoDao.create(my_exec_algo, merge_with_unsaved_data=True)

        string_algo_after = my_exec_algo_created.as_detailed_string()

        LOGGER.info("Before creation: %s", string_algo_before)
        LOGGER.info("After  creation: %s", string_algo_after)

        my_exec_algo_created.trigger_start_execution_date()
        LOGGER.info("Triggered start: %s", my_exec_algo_created.as_detailed_string())

        my_exec_algo_created.trigger_end_execution_date()
        LOGGER.info("Triggered end  : %s", my_exec_algo_created.as_detailed_string())

        my_exec_algo_created.state = EnumState.ALGO_KO

        string_algo_state_updated = my_exec_algo_created.as_detailed_string()
        LOGGER.info("State updated  : %s", string_algo_state_updated)

        nb_after = ExecutableAlgoDao.objects.count()

        self.assertEqual(nb_init + 1, nb_after, "count in DB: expected: nb_init + 1 == nb_after")
Beispiel #7
0
    def setUpTestData(cls):
        """
        setUpClass: this setup is made once for several tests_ methods

        operational database is not impacted by the Django unittests
        """
        cls.init_logger()
        cls.info("Start: setUpTestData on TestCustomizedParameter")
        try:
            arg_one = Argument("angle", "angle (rad)", ProfileItem.DIR.INPUT, 0)
            param_factor = Parameter("factor", "factor on angle", ProfileItem.DIR.INPUT, 1)
            param_phase = Parameter(name="phase", description="added phase constant",
                                    direction=ProfileItem.DIR.INPUT, order_index=2,
                                    db_id=None,
                                    data_format="number",
                                    domain_of_values=None,
                                    label="phase",
                                    default_value="0")

            cls.res_one = Argument("result", "cos(angle)", ProfileItem.DIR.OUTPUT, 0)
            cls.res_two = Argument("result", "sin(angle)", ProfileItem.DIR.OUTPUT, 0)
            cls.res_three = Argument("result", "tan(angle)", ProfileItem.DIR.OUTPUT, 0)

            res_four = Argument("result", "tan(factor*angle+phase)", ProfileItem.DIR.OUTPUT, 0)

            cls.my_pseudo_impl = Implementation(
                "TU ORM impl for CustomizedAlgo", "Python tan from math::my_tan",
                "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
                "math::my_tan_tri", [arg_one, param_factor, param_phase], [res_four])

            # Implementation created in DB => this one will be tested
            #
            cls.my_pseudo_impl_from_db = ImplementationDao.create(cls.my_pseudo_impl)
            cls.my_arg_one = cls.my_pseudo_impl_from_db.find_by_name_input_item("angle")
            cls.my_param_factor = cls.my_pseudo_impl_from_db.find_by_name_input_item("factor")
            cls.my_param_phase = cls.my_pseudo_impl_from_db.find_by_name_input_item("phase")

            cls.info("setUpTestData initialized implem= {}".format(cls.my_pseudo_impl_from_db))
            cls.info("setUpTestData initialized arg_one= {}".format(cls.my_arg_one))
            cls.info("setUpTestData initialized param_factor= {}".format(cls.my_param_factor))
            cls.info("setUpTestData initialized param_phase= {}".format(cls.my_param_phase))

        except Exception as err:
            cls.logger().exception("got exception type=" + type(err).__name__)
            cls.logger().exception("exception as str=" + str(err))
            cls.error("... ended setUpTestData TestCustomizedParameter: Failed: %s")

        cls.info("End: setUpTestData on TestCustomizedParameter")
    def test_output_profile(self):
        """
        Tests the output_profile method
        """

        profile1 = Parameter(name="param",
                             description="description of the new param",
                             direction=Parameter.DIR.OUTPUT,
                             order_index=0,
                             data_format='String',
                             domain_of_values='*',
                             db_id=1)

        profile2 = Argument(name="arg",
                            description="description of the new arg",
                            direction=Argument.DIR.OUTPUT,
                            order_index=1,
                            data_format='Int',
                            domain_of_values='*',
                            db_id=1)

        try:
            imp = Implementation('Name_of_my_implementation',
                                 'description of my implementation',
                                 'Execution_plugin_name',
                                 'library/address/',
                                 output_profile=[profile1, profile2])
        except TypeError:
            self.fail("output_profile raised TypeError unexpectedly!")

        # Testing output_profile as a non-list
        with self.assertRaises(TypeError):
            imp.output_profile = "A list is expected here"

        # Trying to add Output in output_profile list
        profile1.direction = ProfileItem.DIR.INPUT
        with self.assertRaises(ValueError):
            imp.output_profile = [profile1, profile2]

        # Trying another case for adding Output in output_profile list
        profile1.direction = ProfileItem.DIR.OUTPUT
        profile2.direction = ProfileItem.DIR.INPUT
        with self.assertRaises(ValueError):
            imp.output_profile = [profile1, profile2]

        # Sorting
        profile2.direction = ProfileItem.DIR.OUTPUT
        imp.output_profile = [profile2, profile1]
        self.assertEquals(imp.output_profile, [profile1, profile2])
Beispiel #9
0
    def prepare_catalogue_data(cls):
        """
        this setup is made once for several tests_ methods

        operational database is not impacted by the Django unittests
        """
        cls.init_logger()
        if cls.cat_initialized is False:
            cls.cat_initialized = True
            cls.info("Start: prepareCatalogueData on {}".format(cls.__name__))
            t_name = cls.__name__
            try:

                my_fam = FunctionalFamily(name=t_name + " tested family",
                                          description="",
                                          db_id=None,
                                          label="lab family")
                my_algo = Algorithm(name=t_name + "my algo",
                                    description=" desc",
                                    db_id=None,
                                    label="lab",
                                    family=my_fam)

                cls.arg_one = Argument("angle", "angle (rad)",
                                       ProfileItem.DIR.INPUT, 0)
                cls.param_factor = Parameter("factor", "factor on angle",
                                             ProfileItem.DIR.INPUT, 1)
                cls.param_factor.data_format = "number"

                cls.param_phase = Parameter(name="phase",
                                            description="added phase constant",
                                            direction=ProfileItem.DIR.INPUT,
                                            order_index=2,
                                            db_id=None,
                                            data_format="number",
                                            domain_of_values=None,
                                            label="phase",
                                            default_value=0)

                cls.param_phase_with_domain = Parameter(
                    name="phase",
                    description="added phase constant",
                    direction=ProfileItem.DIR.INPUT,
                    order_index=2,
                    db_id=None,
                    data_format="number",
                    domain_of_values="[0, 1.1, 2 ]",
                    label="phase with constraint",
                    default_value=0)

                cls.res_one = Argument("result", "cos(angle)",
                                       ProfileItem.DIR.OUTPUT, 0)
                cls.res_two = Argument("result", "sin(angle)",
                                       ProfileItem.DIR.OUTPUT, 0)
                cls.res_three = Argument("result", "tan(angle)",
                                         ProfileItem.DIR.OUTPUT, 0)

                cls.res_four = Argument("result", "tan(factor*angle+phase)",
                                        ProfileItem.DIR.OUTPUT, 0)

                cls.my_cosinus = Implementation(
                    t_name + " ORM Python Standard cosinus",
                    "Python cosinus from math::cos",
                    "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
                    "math::cos", [cls.arg_one], [cls.res_one])

                cls.my_sinus = Implementation(
                    t_name + " ORM Python Standard sinus",
                    "Python sinus from math::sin",
                    "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
                    "math::sin", [cls.arg_one], [cls.res_two])

                cls.my_tan = Implementation(
                    t_name + " ORM Python Standard tan",
                    "Python tan from math::tan",
                    "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
                    "math::tan", [cls.arg_one], [cls.res_three])

                cls.my_pseudo_impl = Implementation(
                    t_name + " ORM impl for CustomizedAlgo",
                    "Python tan from math::my_tan",
                    "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
                    "ikats.processing.ikats_processing.tests.test_contrib::my_tan",
                    [cls.arg_one, cls.param_factor, cls.param_phase],
                    [cls.res_four],
                    algo=my_algo)

                cls.my_pseudo_impl_with_domain = Implementation(
                    t_name + " ORM impl2 for CustomizedAlgo",
                    "Python tan from math::my_tan_bis",
                    "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
                    "ikats.processing.ikats_processing.tests.test_contrib::my_tan_bis",
                    [
                        cls.arg_one, cls.param_factor,
                        cls.param_phase_with_domain
                    ], [cls.res_four],
                    algo=my_algo)

                # Implementation created in DB => this one will be tested
                #
                cls.my_pseudo_impl_from_db = ImplementationDao.create(
                    cls.my_pseudo_impl)
                cls.my_arg_one = cls.my_pseudo_impl_from_db.find_by_name_input_item(
                    "angle")
                cls.my_param_factor = cls.my_pseudo_impl_from_db.find_by_name_input_item(
                    "factor")
                cls.my_param_phase = cls.my_pseudo_impl_from_db.find_by_name_input_item(
                    "phase")

                cls.info(
                    "prepare_catalogue_data initialized implem= {}".format(
                        cls.my_pseudo_impl_from_db))
                cls.info(
                    "prepare_catalogue_data initialized arg_one= {}".format(
                        cls.my_arg_one))
                cls.info("prepare_catalogue_data initialized param_factor= {}".
                         format(cls.my_param_factor))
                cls.info("prepare_catalogue_data initialized param_phase= {}".
                         format(cls.my_param_phase))

                cls.my_pseudo_impl_with_domain_from_db = ImplementationDao.create(
                    cls.my_pseudo_impl_with_domain)
                cls.my_arg_one_bis = cls.my_pseudo_impl_with_domain_from_db.find_by_name_input_item(
                    "angle")
                cls.my_param_factor_bis = cls.my_pseudo_impl_with_domain_from_db.find_by_name_input_item(
                    "factor")
                cls.my_param_phase_bis = cls.my_pseudo_impl_with_domain_from_db.find_by_name_input_item(
                    "phase")

                cls.info(
                    "prepare_catalogue_data my_pseudo_impl_with_domain_from_db= {}"
                    .format(cls.my_pseudo_impl_with_domain_from_db))
                cls.info("prepare_catalogue_data my_arg_one_bis= {}".format(
                    cls.my_arg_one_bis))
                cls.info(
                    "prepare_catalogue_data my_param_factor_bis= {}".format(
                        cls.my_param_factor_bis))
                cls.info(
                    "prepare_catalogue_data my_param_phase_bis= {}".format(
                        cls.my_param_phase_bis))

                cls.info("End: prepare_catalogue_data on {}".format(
                    cls.__name__))

            except Exception as err:
                cls.logger().exception("got exception type=" +
                                       type(err).__name__)
                cls.logger().exception("exception as str=" + str(err))
                cls.error("... ended prepare_catalogue_data {}: Failed".format(
                    cls.__name__))
Beispiel #10
0
    def test_seq6_delete(self):
        fam_count_before = FunctionalFamilyDao.objects.count()
        algo_count_before = AlgorithmDao.objects.count()
        impl_count_before = ImplementationDao.objects.count()
        prof_count_before = ProfileItemDao.objects.count()

        self.info("Pre-condition: FunctionalFamilyDao count = %s" %
                  fam_count_before)
        self.info("Pre-condition: AlgorithmDao count = %s" % algo_count_before)
        self.info("Pre-condition: ImplementationDao count = %s" %
                  impl_count_before)
        self.info("Pre-condition: ProfileItemDao count = %s" %
                  prof_count_before)

        step = "------ step 1: create tan Tri ------"
        self.info(step)

        family = FunctionalFamilyDao.create(
            FunctionalFamily(name="TU family",
                             description="TU family for tan Tri"))
        algo = AlgorithmDao.create(
            Algorithm(name="TU algo",
                      description="desc TU algo",
                      label="label",
                      family=family))

        self.info("  - family: %s" % str(family))
        self.info("  - algo: %s" % str(algo))

        fam_count_step1 = FunctionalFamilyDao.objects.count()
        algo_count_step1 = AlgorithmDao.objects.count()
        self.info("Parent family created: FunctionalFamilyDao count = %s" %
                  fam_count_step1)
        self.info("Parent algo created: AlgorithmDao count = %s" %
                  algo_count_step1)

        tan_tri = Implementation(
            "TU ORM Python Standard tan TRI", "Python tan TRI from math::tan",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::tan", [TestImplementationDaoCRUD.arg_one],
            [TestImplementationDaoCRUD.res_three])

        tan_tri.algo = algo

        created_tan = ImplementationDao.create(tan_tri)

        impl_count_step1 = ImplementationDao.objects.count()
        prof_count_step1 = ProfileItemDao.objects.count()

        self.info("Once tan Tri created: ImplementationDao count = %s" %
                  impl_count_step1)
        self.info("Once tan Tri created: ProfileItemDao count = %s" %
                  prof_count_step1)

        self.info("  - Original tan Tri oper: %s" % str(tan_tri))
        self.info("  - Created tan Tri oper: %s" % str(created_tan))

        step = "------ step 2:  delete oper tan Tri with parent algo ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan)

        fam_count_step2 = FunctionalFamilyDao.objects.count()
        algo_count_step2 = AlgorithmDao.objects.count()
        impl_count_step2 = ImplementationDao.objects.count()
        prof_count_step2 = ProfileItemDao.objects.count()

        self.info(
            "Step2: once tan Tri deleted: FunctionalFamilyDao count = %s" %
            fam_count_step2)
        self.info("Step2: once tan Tri deleted: AlgorithmDao count = %s" %
                  algo_count_step2)
        self.info("Step2: once tan Tri deleted: ImplementationDao count = %s" %
                  impl_count_step2)
        self.info("Step2: once tan Tri deleted: ProfileItemDao count = %s" %
                  prof_count_step2)

        self.assertEqual(
            fam_count_step2, fam_count_step1,
            "After  delete: family count unchanged: fam_count_step2 == fam_count_step1"
        )
        self.assertEqual(
            algo_count_step2, algo_count_step1,
            "After delete: algo count unchanged: algo_count_step2 == algo_count_step1"
        )
        self.assertEqual(
            impl_count_step2, impl_count_before,
            "After  delete: impl_count_step2 == impl_count_before")
        self.assertEqual(
            prof_count_step2, prof_count_before,
            "After second delete: prof_count_step2 == prof_count_before")

        self.assertTrue(impl_count_step2 < impl_count_step1)
        self.assertTrue(prof_count_step2 < prof_count_step1)
Beispiel #11
0
    def test_seq5_delete(self):
        impl_count_before = ImplementationDao.objects.count()
        prof_count_before = ProfileItemDao.objects.count()

        self.info("Pre-condition: ImplementationDao count = %s" %
                  impl_count_before)
        self.info("Pre-condition: ProfileItemDao count = %s" %
                  prof_count_before)

        step = "------ step 1: create tan + tan Bis ------"
        self.info(step)

        created_tan = ImplementationDao.create(
            TestImplementationDaoCRUD.my_tan)

        impl_count_step1_1 = ImplementationDao.objects.count()
        prof_count_step1_1 = ProfileItemDao.objects.count()

        self.info("Once tan created: ImplementationDao count = %s" %
                  impl_count_step1_1)
        self.info("Once tan created: ProfileItemDao count = %s" %
                  prof_count_step1_1)
        self.info("  created input: " + str(created_tan.input_profile[0]))
        self.info(" created output: " + str(created_tan.output_profile[0]))

        tan_bis = Implementation(
            "TU ORM Python Standard tan BIS", "Python tan BIS from math::tan",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::tan", [created_tan.input_profile[0]],
            [created_tan.output_profile[0]])

        created_tan_bis = ImplementationDao.create(tan_bis)

        impl_count_step1_2 = ImplementationDao.objects.count()
        prof_count_step1_2 = ProfileItemDao.objects.count()

        self.info("Once tan Bis created: ImplementationDao count = %s" %
                  impl_count_step1_2)
        self.info("Once tan Bis created: ProfileItemDao count = %s" %
                  prof_count_step1_2)

        self.info("  - Original tan oper: %s" %
                  str(TestImplementationDaoCRUD.my_tan))
        self.info("  - Created tan oper: %s" % str(created_tan))
        self.info("  - Created tan BIS oper: %s" % str(created_tan_bis))

        step = "------ step 2:  delete oper tan with shared Profile_Items ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan)

        impl_count_step2 = ImplementationDao.objects.count()
        prof_count_step2 = ProfileItemDao.objects.count()

        self.info("Once tan deleted: ImplementationDao count = %s" %
                  impl_count_step2)
        self.info("Once tan deleted: ProfileItemDao count = %s" %
                  prof_count_step2)

        self.assertEqual(
            impl_count_step1_2, impl_count_step2 + 1,
            "After first delete: impl_count_step2 == impl_count_step2 +1")
        self.assertEqual(
            prof_count_step1_2, prof_count_step2,
            "After first delete: no orphan profile_item: prof_count_step1_2 == prof_count_step2"
        )

        step = "------ step 3:  delete oper tan BIS with no more shared Profile_Items ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan_bis)

        impl_count_step3 = ImplementationDao.objects.count()
        prof_count_step3 = ProfileItemDao.objects.count()

        self.info("Once tan Bis deleted: ImplementationDao count = %s" %
                  impl_count_step3)
        self.info("Once tan Bis deleted: ProfileItemDao count = %s" %
                  prof_count_step3)

        self.assertEqual(
            impl_count_step3, impl_count_before,
            "After second delete: impl_count_step3 == impl_count_before")
        self.assertEqual(
            prof_count_step3, prof_count_before,
            "After second delete: prof_count_step3 == prof_count_before")
    def test_input_profile(self):
        """
        Tests the input_profile method cases
        """

        profile1 = Parameter(name="param",
                             description="description of the new param",
                             direction=Parameter.DIR.INPUT,
                             order_index=0,
                             data_format='String',
                             domain_of_values='*',
                             db_id=1)

        profile2 = Argument(name="arg",
                            description="description of the new arg",
                            direction=Argument.DIR.INPUT,
                            order_index=1,
                            data_format='Int',
                            domain_of_values='*',
                            db_id=1)

        try:
            imp = Implementation('Name_of_my_implementation',
                                 'description of my implementation',
                                 'Execution_plugin_name',
                                 'library/address/',
                                 input_profile=[profile1, profile2])
        except TypeError:
            self.fail("input_profile raised TypeError unexpectedly!")

        # Testing input_profile as a non-list
        with self.assertRaises(TypeError):
            imp.input_profile = "A list is expected here"

        # Trying to add Output in Input_profile list
        profile1.direction = Parameter.DIR.OUTPUT
        with self.assertRaises(ValueError):
            imp.input_profile = [profile1, profile2]

        # Trying another case for adding Output in Input_profile list
        profile1.direction = Parameter.DIR.INPUT
        profile2.direction = Parameter.DIR.OUTPUT
        with self.assertRaises(ValueError):
            imp.input_profile = [profile1, profile2]

        # Sorting
        profile2.direction = Parameter.DIR.INPUT
        imp.input_profile = [profile2, profile1]
        self.assertEquals(imp.input_profile, [profile1, profile2])

        # Finding inputs ...
        # ... among Arguments or Parameters
        item1 = imp.find_by_name_input_item("param")
        self.assertEquals(profile1, item1)
        item2 = imp.find_by_name_input_item("arg")
        self.assertEquals(profile2, item2)
        # ... only among Arguments
        item3 = imp.find_by_name_input_item("param", accepted_type=Argument)
        self.assertEquals(None, item3)
        item4 = imp.find_by_name_input_item("arg", accepted_type=Argument)
        self.assertEquals(profile2, item4)
        # ... only among Parameters
        item5 = imp.find_by_name_input_item("param", accepted_type=Parameter)
        self.assertEquals(profile1, item5)
        item6 = imp.find_by_name_input_item("arg", accepted_type=Parameter)
        self.assertEquals(None, item6)

        # ... mismatched name
        item7 = imp.find_by_name_input_item("mismatched_name")
        self.assertEquals(None, item7)