def test_add_conditionailty(self):
     # Try to insert normal trivial conditionality
     study_type_service = StudyTypeService(self.study_type_name, self.user)
     # study_type_service.clear_all_conditionalities()
     name = "always_true_conditionality"
     description = "always return true"
     module_path = "nlm.conditionality.always_true_conditionality"
     study_type_service.add_conditionality(name, description, module_path)
     study_type_service.remove_conditionality(module_path)
    def test_create_conditionality_parameter(self):
        study_type_service = StudyTypeService(self.study_type_name, self.user)
        name = "random with parameterized threshold"
        description = "random with parameterized threshold"
        module_path = "nlm.conditionality.parameterized_conditionality"
        try:
            study_type_service.remove_conditionality(module_path)
        except:
            pass        
        new_conditionality = study_type_service.add_conditionality(name, description, module_path)

        conditionality_parameter_name = "nlm.test.test_conditionality.ramdom.threshold"
        try:
            study_type_service.remove_conditionality_parameter(new_conditionality, conditionality_parameter_name)
        except:
            pass
        study_type_service.set_conditionality_parameter(new_conditionality, conditionality_parameter_name, 0.2)
        study_type_service.remove_conditionality_parameter(new_conditionality, conditionality_parameter_name)
        study_type_service.remove_conditionality(module_path)
 def test_use_conditionality_parameter_with_setting(self):
     study_type_service = StudyTypeService(self.study_type_name, self.user)
     name = "random with parameterized threshold"
     description = "random with parameterized threshold"
     module_path = "nlm.conditionality.parameterized_conditionality"
     try:
         study_type_service.remove_conditionality(module_path)
     except:
         pass     
     new_conditionality = study_type_service.add_conditionality(name, description, module_path)
     
     conditionality_parameter_name = "nlm.test.test_conditionality.ramdom.threshold"
     try:
         study_type_service.remove_conditionality_parameter(new_conditionality, conditionality_parameter_name)
     except:
         pass
     study_type_service.set_conditionality_parameter(new_conditionality, conditionality_parameter_name, 0.2)
     
     
     conditionality_parameter_name2 = "nlm.test.test_conditionality.ramdom.test_str"
     try:
         study_type_service.remove_conditionality_parameter(new_conditionality, conditionality_parameter_name2)
     except:
         pass
     study_type_service.set_conditionality_parameter(new_conditionality, conditionality_parameter_name2, "test string")
     
     
     
     params = ProgramletParameters(
         "Test_Test",
         study_type_service,
         new_conditionality)
     study_type_service.call_conditionality(module_path, parameters=params)
     
     study_type_service.remove_conditionality_parameter(new_conditionality, conditionality_parameter_name)
     study_type_service.remove_conditionality_parameter(new_conditionality, conditionality_parameter_name2)
     study_type_service.remove_conditionality(module_path)