How to use set_data_type method in autotest

Best Python code snippet using autotest_python

schemas.py

Source:schemas.py Github

copy

Full Screen

...78# region locations79table_name = "locations"80text_fields = ['Site ID', 'Hospital']81for col in text_fields:82 input_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*")83# endregion84# region surgeons85table_name = "surgeons"86text_fields = ['Surgeon ID', 'Name']87for col in text_fields:88 input_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*")89# endregion90# region cost_matrix91table_name = "cost_matrix"92text_fields = ['Origin Site ID', 'Dest. Site ID']93input_schema.set_data_type(table_name, 'Transp. Cost', must_be_int=False, min=0, max=float('inf'),94 inclusive_min=True, inclusive_max=False)95for col in text_fields:96 input_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*")97input_schema.add_foreign_key(table_name, 'locations', [('Origin Site ID', 'Site ID')])98input_schema.add_foreign_key(table_name, 'locations', [('Dest. Site ID', 'Site ID')])99# endregion100# region tissues101table_name = "tissues"102text_fields = ['Tissue ID', 'Current Site ID']103flag_fields = ['PK', 'DSAEK', 'DMEK', 'Diabetes', 'Cancer', 'Artificial Lens', 'Moderate Folds',104 'LASIK Scar', 'Returned']105input_schema.set_data_type(table_name, 'Death to Recovery (hrs.)', must_be_int=False, min=0, max=100,106 inclusive_min=False, inclusive_max=True)107input_schema.set_data_type(table_name, 'Death to Surgery (days)', must_be_int=False, min=0, max=100,108 inclusive_min=False, inclusive_max=True)109input_schema.set_data_type(table_name, 'Death to Cooling (hrs.)', must_be_int=False, min=0, max=100,110 inclusive_min=False, inclusive_max=True)111input_schema.set_data_type(table_name, 'Donor Age', must_be_int=True, min=0, max=120,112 inclusive_min=False, inclusive_max=True)113input_schema.set_data_type(table_name, 'Cell Count', must_be_int=True, min=0, max=float('inf'),114 inclusive_min=False, inclusive_max=False)115input_schema.set_data_type(table_name, 'Clear Zone', must_be_int=False, min=0, max=50,116 inclusive_min=True, inclusive_max=False)117for col in text_fields:118 input_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*")119for col in flag_fields:120 input_schema.set_data_type(table_name, col, must_be_int=True, min=0, max=1, inclusive_min=True, inclusive_max=True)121input_schema.add_foreign_key(table_name, 'locations', [('Current Site ID', 'Site ID')])122# endregion123# region requests124table_name = "requests"125text_fields = ['Site ID', 'Surgeon ID']126flag_fields = ['Exclude Tissue Returned', 'Exclude Cancer', 'Exclude Diabetes', 'Exclude LASIK Scars',127 'Exclude Mated Set', 'Exclude Moderate Folds', 'Exclude Artificial Lens']128input_schema.set_data_type(table_name, 'Tissue Use', strings_allowed=['PK', 'DSAEK', 'DMEK'])129input_schema.set_data_type(table_name, 'Age Min', must_be_int=True, min=0, max=120,130 inclusive_min=True, inclusive_max=True)131input_schema.set_data_type(table_name, 'Age Max', must_be_int=True, min=0, max=120,132 inclusive_min=True, inclusive_max=True)133input_schema.set_data_type(table_name, 'Cell Count Min', must_be_int=True, min=0, max=float('inf'),134 inclusive_min=True, inclusive_max=False)135input_schema.set_data_type(table_name, 'Death to Recovery Max (hrs.)', must_be_int=False, min=0, max=100,136 inclusive_min=True, inclusive_max=True)137input_schema.set_data_type(table_name, 'Death to Surgery Max (days)', must_be_int=False, min=0, max=100,138 inclusive_min=True, inclusive_max=True)139input_schema.set_data_type(table_name, 'Death to Cooling Max (hrs.)', must_be_int=False, min=0, max=100,140 inclusive_min=True, inclusive_max=True)141input_schema.set_data_type(table_name, 'Clear Zone Min', must_be_int=False, min=0, max=50,142 inclusive_min=True, inclusive_max=False)143for col in text_fields:144 input_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*")145for col in flag_fields:146 input_schema.set_data_type(table_name, col, must_be_int=True, min=0, max=1, inclusive_min=True, inclusive_max=True)147input_schema.add_foreign_key(table_name, 'surgeons', [('Surgeon ID', 'Surgeon ID')])148input_schema.add_foreign_key(table_name, 'locations', [('Site ID', 'Site ID')])149input_schema.add_data_row_predicate(table_name, predicate_name="Age Min <= Age Max",150 predicate=lambda row: row['Age Min'] <= row['Age Max'])151# endregion152# region surgeons_pref153table_name = "surgeons_pref"154text_fields = ['Surgeon ID']155score_fields = ['Cell Count Min', 'Age Range', 'Death to Recovery Max (hrs.)', 'Death to Surgery Max (days)',156 'Death to Cooling Max (hrs.)', 'Tissue Origin']157input_schema.set_data_type(table_name, 'Tissue Use', strings_allowed=['PK', 'DSAEK', 'DMEK'])158for col in text_fields:159 input_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*")160for col in score_fields:161 input_schema.set_data_type(table_name, col, must_be_int=False, min=0, max=1, inclusive_min=True, inclusive_max=True)162input_schema.add_foreign_key(table_name, 'surgeons', [('Surgeon ID', 'Surgeon ID')])163input_schema.add_data_row_predicate(table_name, predicate_name="Scores add up to 1.0",164 predicate=lambda row: abs(sum(row[col_] for col_ in score_fields) - 1) < 1e-4)165# endregion166# endregion167# region APPLY DATA TYPES AND PREDICATES TO THE OUTPUT SCHEMA168# region rpt_matching169table_name = "rpt_matching"170nullable_text_fields = ['Tissue ID', 'Tissue ID - Alt. 1', 'Tissue ID - Alt. 2']171nullable_float_field = ['Transp. Cost', 'Transp. Cost - Alt. 1', 'Transp. Cost - Alt. 2', 'Penalty']172output_schema.set_data_type(table_name, 'Request ID', number_allowed=False, strings_allowed="*")173for col in nullable_text_fields:174 output_schema.set_data_type(table_name, col, number_allowed=False, strings_allowed="*", nullable=True)175for col in nullable_float_field:176 output_schema.set_data_type(table_name, col, must_be_int=False, min=0, max=float('inf'),177 inclusive_min=True, inclusive_max=False, nullable=True)178for col in ['Score', 'Score - Alt. 1', 'Score - Alt. 2']:179 output_schema.set_data_type(table_name, col, must_be_int=False, min=-float('inf'), max=float('inf'),180 inclusive_min=False, inclusive_max=False, nullable=True)181# endregion...

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 autotest 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