How to use build_test_case method in Testify

Best Python code snippet using Testify_python

test_functional_preproc.py

Source:test_functional_preproc.py Github

copy

Full Screen

...83 wf_inputs_string = wf_inputs_string.replace(base_dir, \84 "BASE_DIRECTORY_HERE")85 wf_inputs_string = wf_inputs_string.replace(func_scan, "IN_FILE_A_HERE", 1)86 wf_inputs_string = wf_inputs_string.replace(func_scan, "IN_FILES_HERE")87 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)88 89 assert flag == 2, err90def test_workflow_func_motion_correct_slice_time():91 import os92 import pkg_resources as p93 from qap.functional_preproc import run_func_motion_correct94 from qap.workflow_utils import build_test_case95 96 func_scan = p.resource_filename("qap", os.path.join(test_sub_dir, \97 "rest_1", \98 "functional_scan", \99 "rest.nii.gz"))100 ref_graph = p.resource_filename("qap", os.path.join("test_data", \101 "workflow_reference", \102 "func_motion_correct_slice_time", \103 "graph_func_motion_correct" \104 "_slice_time.dot"))105 106 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \107 "workflow_reference", \108 "func_motion_correct_slice_time", \109 "wf_inputs.txt")) 110 111 # build the workflow112 wf, base_dir = run_func_motion_correct(func_scan, 0, "End", True, False)113 114 115 # get the workflow inputs of the workflow being tested116 wf_inputs_string = str(wf.inputs).replace("\n","")117 118 wf_inputs_string = wf_inputs_string.replace(base_dir, \119 "BASE_DIRECTORY_HERE")120 wf_inputs_string = wf_inputs_string.replace(func_scan, "IN_FILE_A_HERE",\121 1)122 wf_inputs_string = wf_inputs_string.replace(func_scan, "IN_FILES_HERE")123 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)124 125 assert flag == 2, err126 127 128def test_workflow_functional_brain_mask_3dautomask():129 import os130 import pkg_resources as p131 from qap.functional_preproc import run_functional_brain_mask132 from qap.workflow_utils import build_test_case133 134 func_motion = p.resource_filename("qap", os.path.join(test_sub_dir, \135 "rest_1", \136 "func_motion_correct", \137 "rest_calc_tshift_resample_" \138 "volreg.nii.gz"))139 ref_graph = p.resource_filename("qap", os.path.join("test_data", \140 "workflow_reference", \141 "functional_brain_mask_3dautomask", \142 "graph_functional_brain_mask" \143 "_3dautomask.dot"))144 145 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \146 "workflow_reference", \147 "functional_brain_mask_3dautomask", \148 "wf_inputs.txt"))149 150 # build the workflow151 wf, base_dir = run_functional_brain_mask(func_motion, use_bet=False, \152 run=False)153 154 # get the workflow inputs of the workflow being tested155 wf_inputs_string = str(wf.inputs).replace("\n","")156 157 wf_inputs_string = wf_inputs_string.replace(base_dir, \158 "BASE_DIRECTORY_HERE")159 wf_inputs_string = wf_inputs_string.replace(func_motion, "IN_FILE_HERE")160 161 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)162 163 assert flag == 2, err164 165 166 167def test_workflow_functional_brain_mask_BET():168 import os169 170 import pkg_resources as p171 from qap.functional_preproc import run_functional_brain_mask172 from qap.workflow_utils import build_test_case173 174 func_motion = p.resource_filename("qap", os.path.join(test_sub_dir, \175 "rest_1", \176 "func_motion_correct", \177 "rest_calc_tshift_resample_" \178 "volreg.nii.gz"))179 180 ref_graph = p.resource_filename("qap", os.path.join("test_data", \181 "workflow_reference", \182 "functional_brain_mask_BET", \183 "graph_functional_brain_mask_BET.dot"))184 185 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \186 "workflow_reference", \187 "functional_brain_mask_BET", \188 "wf_inputs.txt"))189 190 # build the workflow191 wf, base_dir = run_functional_brain_mask(func_motion, use_bet=True, \192 run=False)193 # get the workflow inputs of the workflow being tested194 wf_inputs_string = str(wf.inputs).replace("\n","")195 196 wf_inputs_string = wf_inputs_string.replace(base_dir, \197 "BASE_DIRECTORY_HERE")198 wf_inputs_string = wf_inputs_string.replace(func_motion, "IN_FILE_HERE")199 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)200 201 assert flag == 2, err202def test_workflow_mean_functional():203 import os204 import pkg_resources as p205 from qap.functional_preproc import run_mean_functional206 from qap.workflow_utils import build_test_case207 208 func_motion = p.resource_filename("qap", os.path.join(test_sub_dir, \209 "rest_1", \210 "func_motion_correct", \211 "rest_calc_tshift_resample_" \212 "volreg.nii.gz"))213 214 ref_graph = p.resource_filename("qap", os.path.join("test_data", \215 "workflow_reference", \216 "mean_functional", \217 "graph_mean_functional.dot"))218 219 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \220 "workflow_reference", \221 "mean_functional", \222 "wf_inputs.txt"))223 224 # build the workflow225 wf, base_dir = run_mean_functional(func_motion, False)226 # get the workflow inputs of the workflow being tested227 wf_inputs_string = str(wf.inputs).replace("\n","")228 229 wf_inputs_string = wf_inputs_string.replace(base_dir, \230 "BASE_DIRECTORY_HERE")231 wf_inputs_string = wf_inputs_string.replace(func_motion, "IN_FILE_HERE")232 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)233 234 assert flag == 2, err235def run_all_tests_functional_preproc():236 test_get_idx_whole_timeseries()237 test_get_idx_partial_timeseries()238 test_get_idx_partial_timeseries_overshoot()239 test_workflow_func_motion_correct_no_slice_time()240 test_workflow_func_motion_correct_slice_time()241 test_workflow_functional_brain_mask_3dautomask()242 test_workflow_functional_brain_mask_BET()243 test_workflow_mean_functional() 244 245 246

Full Screen

Full Screen

test_anatomical_preproc.py

Source:test_anatomical_preproc.py Github

copy

Full Screen

...27 28 wf_inputs_string = wf_inputs_string.replace(base_dir, \29 "BASE_DIRECTORY_HERE")30 wf_inputs_string = wf_inputs_string.replace(anat_scan, "IN_FILE_HERE")31 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)32 33 assert flag == 2, err34 35 36def test_workflow_anatomical_skullstrip():37 ''' unit test for the anatomical skullstrip workflow BUILDER '''38 import os39 import commands40 41 import pkg_resources as p42 from qap.anatomical_preproc import run_anatomical_skullstrip43 from qap.workflow_utils import build_test_case44 anat_reorient = p.resource_filename("qap", os.path.join(test_sub_dir, \45 "anat_1", \46 "anatomical_reorient", \47 "mprage_resample.nii.gz"))48 ref_graph = p.resource_filename("qap", os.path.join("test_data", \49 "workflow_reference", \50 "anatomical_skullstrip", \51 "graph_anatomical_skullstrip.dot"))52 53 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \54 "workflow_reference", \55 "anatomical_skullstrip", \56 "wf_inputs.txt"))57 # build the workflow and return it58 wf, base_dir = run_anatomical_skullstrip(anat_reorient, False)59 # get the workflow inputs of the workflow being tested60 wf_inputs_string = str(wf.inputs).replace("\n","")61 62 wf_inputs_string = wf_inputs_string.replace(base_dir, \63 "base_directory_here")64 wf_inputs_string = wf_inputs_string.replace(anat_reorient, "in_file_here", 1)65 wf_inputs_string = wf_inputs_string.replace(anat_reorient, "in_file_a_here")66 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)67 68 assert flag == 2, err69def test_workflow_flirt_anatomical_linear_registration():70 ''' unit test for the anatomical reorient workflow BUILDER '''71 import os72 import pkg_resources as p73 from qap.anatomical_preproc import run_flirt_anatomical_linear_registration74 from qap.workflow_utils import build_test_case75 anat_brain = p.resource_filename("qap", os.path.join(test_sub_dir, \76 "anat_1", \77 "anatomical_brain", \78 "mprage_resample_calc.nii.gz"))79 template_brain = p.resource_filename("qap", os.path.join("test_data", \80 "MNI152_T1_2mm_brain.nii.gz"))81 ref_graph = p.resource_filename("qap", os.path.join("test_data", \82 "workflow_reference", \83 "flirt_anatomical_linear_registration", \84 "graph_flirt_anatomical_linear" \85 "_registration.dot"))86 87 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \88 "workflow_reference", \89 "flirt_anatomical_linear_registration", \90 "wf_inputs.txt"))91 # build the workflow and return it92 wf, base_dir = run_flirt_anatomical_linear_registration(anat_brain, \93 template_brain, \94 False)95 # get the workflow inputs of the workflow being tested96 wf_inputs_string = str(wf.inputs).replace("\n","")97 98 wf_inputs_string = wf_inputs_string.replace(base_dir, \99 "base_directory_here")100 wf_inputs_string = wf_inputs_string.replace(anat_brain, "in_file_here")101 wf_inputs_string = wf_inputs_string.replace(template_brain, \102 "reference_here")103 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)104 105 assert flag == 2, err106 107 108def test_workflow_segmentation():109 ''' unit test for the segmentation workflow BUILDER '''110 import os111 import commands112 113 import pkg_resources as p114 from qap.anatomical_preproc import run_segmentation_workflow115 from qap.workflow_utils import build_test_case116 anat_brain = p.resource_filename("qap", os.path.join(test_sub_dir, \117 "anat_1", \118 "anatomical_brain", \119 "mprage_resample_calc.nii.gz"))120 ref_graph = p.resource_filename("qap", os.path.join("test_data", \121 "workflow_reference", \122 "segmentation", \123 "graph_segmentation.dot"))124 ref_inputs = p.resource_filename("qap", os.path.join("test_data", \125 "workflow_reference", \126 "segmentation", \127 "wf_inputs.txt"))128 # build the workflow and return it129 wf, base_dir = run_segmentation_workflow(anat_brain, False)130 # get the workflow inputs of the workflow being tested131 wf_inputs_string = str(wf.inputs).replace("\n","")132 133 wf_inputs_string = wf_inputs_string.replace(base_dir, \134 "base_directory_here")135 list_input = "['" + anat_brain + "']"136 wf_inputs_string = wf_inputs_string.replace(list_input, "in_files_here")137 flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)138 139 assert flag == 2, err140def run_all_tests_anatomical_preproc():141 test_workflow_anatomical_reorient()142 test_workflow_anatomical_skullstrip()143 test_workflow_flirt_anatomical_linear_registration()...

Full Screen

Full Screen

json.py

Source:json.py Github

copy

Full Screen

...62 """Check to see if specified test at endpoint should be auto run"""63 with open(directory) as stream:64 data = json.load(stream)65 test_data = data[endpoint]66 auto_run = parse.build_test_case(test_data, test_name)["auto_run"]67 return auto_run68def endpoint_load_all_tests(directory, endpoint):69 """Load list of all test cases from an endpoint"""70 with open(directory) as stream:71 data = json.load(stream)72 test_dict = data[endpoint]73 LOG.debug("Loaded test data : %s", test_dict)74 return test_dict75def endpoint_load_test_case(directory, endpoint, test_name):76 """Load test description, payload, and expected results at index"""77 with open(directory) as stream:78 data = json.load(stream)79 test_data = data[endpoint]80 return parse.build_test_case(test_data, test_name)81def endpoint_load_base_path(directory, endpoint):82 """Load base path from endpoint"""83 return endpoint_load_test_path(directory, endpoint, BASE)84def endpoint_load_test_path(directory, endpoint, test_name):85 """Load expected path for specified endpoint and test"""86 with open(directory) as stream:87 data = json.load(stream)88 test_data = data[endpoint]89 path = parse.build_test_case(test_data, test_name)["path"]90 return path91def endpoint_load_base_parameters(directory, endpoint):92 """Load base parameters from endpoint"""93 return endpoint_load_test_parameters(directory, endpoint, BASE)94def endpoint_load_test_parameters(directory, endpoint, test_name):95 """Load expected parameters for specified endpoint and test"""96 with open(directory) as stream:97 data = json.load(stream)98 test_data = data[endpoint]99 parameters = parse.build_test_case(test_data, test_name)["parameters"]100 return parameters101def endpoint_load_base_payload(directory, endpoint):102 """Load base payload from endpoint"""103 return endpoint_load_test_payload(directory, endpoint, BASE)104def endpoint_load_test_payload(directory, endpoint, test_name):105 """Load expected payload for specified endpoint and test"""106 with open(directory) as stream:107 data = json.load(stream)108 test_data = data[endpoint]109 payload = parse.build_test_case(test_data, test_name)["payload"]110 return payload111def endpoint_load_base_status_codes(directory, endpoint):112 """Load base status_code from endpoint"""113 return endpoint_load_test_status_codes(directory, endpoint, BASE)114def endpoint_load_test_status_codes(directory, endpoint, test_name):115 """Load expected status code for specified endpoint and test"""116 with open(directory) as stream:117 data = json.load(stream)118 test_data = data[endpoint]119 status_codes = parse.build_test_case(test_data, test_name)["status_code"]120 return status_codes121def endpoint_load_base_response(directory, endpoint):122 """Load base response from endpoint"""123 return endpoint_load_test_response(directory, endpoint, BASE)124def endpoint_load_test_response(directory, endpoint, test_name):125 """Load expected response for specified endpoint and test"""126 with open(directory) as stream:127 data = json.load(stream)128 test_data = data[endpoint]129 response = parse.build_test_case(test_data, test_name)["response"]130 return response131###################################################################################################132# JSON Utilites133###################################################################################################134def load_response_data(response):135 """Return the data of the response body"""136 try:137 response_data = json.loads(response.text)138 except json.decoder.JSONDecodeError:139 response_data = {}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testify automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful