def test_get_parameter_tree(project_name='py_common'): """Should return the parameter set as a tree for the given project. """ project = project_processor.get_project_by_name(project_name=project_name) parameter = parameter_processor.get_parameter_tree(project['database']) print(parameter) return parameter
def add_parameters_to_test_project(profile, project='py_common', dictionary=None): if type(project) not in [dict, OrderedDict]: project = project_processor.get_project_by_name(project_name=project) print('project: ') print(project) print('') print('') project_profile = generic_processor.get_fully_qualified_profile_from_filesystem( profile) profile_path = project_profile['profiles'] + '/' + profile setup = parameter_processor.add_parameters_to_project_from_filesystem( profile_path, project, full_path=True, profile_name=profile, profile_dictionary=dictionary) print('mars profile: ') print(setup['profile']) print('') print('mars structures: ') print(setup['structures']) print('') print('mars templates: ') print(setup['templates']) print('') print('mars translators: ') print(setup['translators']) print('')
def test_workflow_setup(project, profile="standard"): """Workflow tests relating to the test project. """ if type(project) not in [dict, OrderedDict]: project = project_processor.get_project_by_name(project) test_workflows = workflow_test.test_add_workflows_from_filesystem( project, profile=profile) return test_workflows
def test_get_components(project_name='py_common'): """Should return the components that are part of a given project. """ project = project_processor.get_project_by_name(project_name) test_components = project_processor.get_all_components(project=project) print('py_common components: ') print(test_components) print('') return project
def test_add_function(project_name='py_common', component_name='py_common'): """Tests adding new functions to the test project. """ function = None project = project_processor.get_project_by_name(project_name) component = component_processor.get_current_component_by_name( project['database'], component_name) function = function_test.test_create_new_function(project, component, function) return function
def update_parameter(): """ This method is a generic handling of updates to project parameters, including groups, structures, templates, and fields. It should take a parameters object that has a subobject called 'update', which should be an array of update dictionaries. Each update in the array should consist of whichever of the following keys are necessary to perform the requested action: update: contains the key value pairs of changes to be made to the system. changes: a list of changes to be made to an existing thing. _id: the id of the thing to be updated or removed. action: a string, indicating 'add', 'update', 'remove'. """ project = project_processor.get_project_by_name('py_common') database = project['database'] if request.method == 'POST': updates = request.get_json(silent=True)['update'] update_result = parameter_router.modify_parameters(database, updates) return generic_model.JSONEncoder().encode(update_result)
def get_groups(): project = project_processor.get_project_by_name('py_common') database = project['database'] groups = parameter_router.get_groups(database) groups = generic_model.JSONEncoder().encode(groups) return groups
def get_structures(): project = project_processor.get_project_by_name('py_common') database = project['database'] parameters = parameter_router.get_all_parameters(database) parameters = generic_model.JSONEncoder().encode(parameters) return parameters
def perform_fresh_filesystem_setup(profile='standard'): """Test function to blow away all project data and recreate from filesystem. """ profile_dictionary = get_profile_dictionary(profile=profile) print('Testing for profile: ') print(profile_dictionary) print('') print('') reset_projects_with_components(profile=profile) project = project_processor.get_project_by_name('py_common') print('Test project: ') print(project) print('') print('') components = component_processor.get_all_components(project['database']) print('Components:') print(components) print('') print('') component = components[0] print('Test component: ') print(component) print('') print('') print('all functions before entry: ') print(function_processor.get_current_functions(project)) print('') print('') function_getter = function_processor.get_functions_for_component_closure( project, profile=profile, scope='internal') for component in components: functions = function_getter(component) print('functions: ') print(functions) print('') print('') function_adder = component_processor.add_functions_to_component_closure( project, source='database', profile=profile) components = list(map(function_adder, components)) print('updated components: ') print(components) print('') print('') print('') print('Setting up structures: ') add_parameters_to_test_project(profile, project=project, dictionary=profile_dictionary) print('') print('') print('') print('Setting up the test workflows: ') test_workflow_setup(project, profile=profile) test_workflow = workflow_test.test_get_workflow( project, workflow_name='test_chained') print('The test workflow: ') print(test_workflow) print('') print('') print('Testing evaluation of workflow multiple times: ') number_times = 10 evaluations = evaluation_test.test_make_evaluations(project, test_workflow, count=number_times) print('Evaluations: ') print(evaluations) print('') print('') print('Getting the records for the evaluations: ') records = evaluation_test.test_get_evaluation_records(project, evaluations) print('Records: ') print(records) print('') print('') print('Adding a name to one of the evaluations to test: ') evaluation = evaluation_test.test_add_evaluation_name( project, test_workflow, 'starred_evaluation') print('Evaluation: ') print(evaluation) print('') print('') print( 'Testing evaluation of a workflow that is dependent on the last evaluation of another workflow: ' ) workflow_test.test_last_evaluation_workflow(project) print('') print('') print( 'Testing evaluation of a workflow that is dependent on a named evaluation: ' ) workflow_test.test_named_evaluation_workflow(project) print('') print('') print('Testing an evaluation with a custom structure: ') test_records = workflow_test.test_custom_structure_workflow(project) print('') print('') return test_records