How to use validate_inputs method in pandera

Best Python code snippet using pandera_python

test_preprocessor.py

Source:test_preprocessor.py Github

copy

Full Screen

...67 schedule_test = mock_data_generator(['CSC225','SENG275'],['CSC226'],['CSC230'], 1, 1)68 program_enrollment_test = json.load(open('../data/real/programEnrollmentData.json', 'r'))69 70 course_enrollment_test = {'key1':'value1'}71 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)72 assert not valid73 assert 'Expected historical course enrollment to be a list not' in error74 75 course_enrollment_test = ['offering']76 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)77 assert not valid78 assert 'Expected offering to be a dict not' in error79 offering = {"maximumEnrollment": 0, "subjectCourse": "CSC105"}80 course_enrollment_test = [offering]81 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)82 assert not valid83 assert 'No "term" field in course offering' in error84 offering = {"term": "202301", "subjectCourse": "CSC105"}85 course_enrollment_test = [offering]86 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)87 assert not valid88 assert 'No "maximumEnrollment" field in course offering' in error89 offering = {"term": "202301", "maximumEnrollment": 0}90 course_enrollment_test = [offering]91 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)92 assert not valid93 assert 'No "subjectCourse" field in course offering' in error94 offering = {"term": 202301,95 "maximumEnrollment": 0,96 "subjectCourse": "CSC105"97 }98 course_enrollment_test = [offering]99 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)100 assert not valid101 assert 'Expected "term" field to be string not' in error102 offering = {"term": '202301',103 "maximumEnrollment": '0',104 "subjectCourse": "CSC105"105 }106 course_enrollment_test = [offering]107 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)108 assert not valid109 assert 'Expected "maximumEnrollment" field to be int not' in error110 offering = {"term": '202301',111 "maximumEnrollment": 0,112 "subjectCourse": 1113 }114 course_enrollment_test = [offering]115 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)116 assert not valid117 assert 'Expected "subjectCourse" field to be string not' in error118def test_validate_input_invalid_program_enrolment():119 schedule_test = mock_data_generator(['CSC225','SENG275'],['CSC226'],['CSC230'], 1, 1)120 course_enrollment_test = generate_course_enrollment(['CSC225','SENG275'] ,121 ['CSC226'], 122 ['CSC230'], 123 ['202109', '202201', '202205', '202209', '202301'])124 program_enrollment_test = []125 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)126 assert not valid127 assert 'Expected historical program enrollment to be a dict not' in error128 program_enrollment_test = {"2014":[]}129 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)130 assert not valid131 assert 'Expected yearly enrollment item to be a dict not' in error132 program_enrollment_test = {"2014" :{ 133 "2" : 68,134 "2T" : 8,135 "3" : 54,136 "4" : 21,137 "5" : 17,138 "6" : 4,139 "7" : 1140 }141 }142 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)143 assert not valid144 assert 'No "1" field in ' in error145 program_enrollment_test = {"2014" :{ "1" : 84,146 "2T" : 8,147 "3" : 54,148 "4" : 21,149 "5" : 17,150 "6" : 4,151 "7" : 1152 }153 }154 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)155 assert not valid156 assert 'No "2" field in ' in error157 program_enrollment_test = {"2014" :{ "1" : 84,158 "2" : 68,159 "3" : 54,160 "4" : 21,161 "5" : 17,162 "6" : 4,163 "7" : 1164 }165 }166 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)167 assert not valid168 assert 'No "2T" field in ' in error169 program_enrollment_test = {"2014" :{ "1" : 84,170 "2" : 68,171 "2T" : 54,172 "4" : 21,173 "5" : 17,174 "6" : 4,175 "7" : 1176 }177 }178 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)179 assert not valid180 assert 'No "3" field in ' in error181 program_enrollment_test = {"2014" :{ "1" : 84,182 "2" : 68,183 "2T" : 54,184 "3" : 21,185 "5" : 17,186 "6" : 4,187 "7" : 1188 }189 }190 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)191 assert not valid192 assert 'No "4" field in ' in error193 program_enrollment_test = {"2014" :{ "1" : 84,194 "2" : 68,195 "2T" : 54,196 "3" : 21,197 "4" : 17,198 "6" : 4,199 "7" : 1200 }201 }202 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)203 assert not valid204 assert 'No "5" field in ' in error205 program_enrollment_test = {"2014" :{ "1" : 84,206 "2" : 68,207 "2T" : 54,208 "3" : 21,209 "4" : 17,210 "5" : 4,211 "7" : 1212 }213 }214 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)215 assert not valid216 assert 'No "6" field in ' in error217 program_enrollment_test = {"2014" :{ "1" : 84,218 "2" : 68,219 "2T" : 54,220 "3" : 21,221 "4" : 17,222 "5" : 4,223 "6" : 1224 }225 }226 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)227 assert not valid228 assert 'No "7" field in ' in error229 program_enrollment_test = {"2014" :{ "1" : '84',230 "2" : 68,231 "2T" : 8,232 "3" : 54,233 "4" : 21,234 "5" : 17,235 "6" : 4,236 "7" : 1237 }238 }239 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)240 assert not valid241 assert 'Expected "1" field to be int not' in error242 program_enrollment_test = {"2014" :{ "1" : 84,243 "2" : '68',244 "2T" : 8,245 "3" : 54,246 "4" : 21,247 "5" : 17,248 "6" : 4,249 "7" : 1250 }251 }252 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)253 assert not valid254 assert 'Expected "2" field to be int not' in error255 program_enrollment_test = {"2014" :{ "1" : 84,256 "2" : 68,257 "2T" : '8',258 "3" : 54,259 "4" : 21,260 "5" : 17,261 "6" : 4,262 "7" : 1263 }264 }265 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)266 assert not valid267 assert 'Expected "2T" field to be int not' in error268 program_enrollment_test = {"2014" :{ "1" : 84,269 "2" : 68,270 "2T" : 8,271 "3" : '54',272 "4" : 21,273 "5" : 17,274 "6" : 4,275 "7" : 1276 }277 }278 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)279 assert not valid280 assert 'Expected "3" field to be int not' in error281 program_enrollment_test = {"2014" :{ "1" : 84,282 "2" : 68,283 "2T" : 8,284 "3" : 54,285 "4" : '21',286 "5" : 17,287 "6" : 4,288 "7" : 1289 }290 }291 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)292 assert not valid293 assert 'Expected "4" field to be int not' in error294 program_enrollment_test = {"2014" :{ "1" : 84,295 "2" : 68,296 "2T" : 8,297 "3" : 54,298 "4" : 21,299 "5" : '17',300 "6" : 4,301 "7" : 1302 }303 }304 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)305 assert not valid306 assert 'Expected "5" field to be int not' in error307 program_enrollment_test = {"2014" :{ "1" : 84,308 "2" : 68,309 "2T" : 8,310 "3" : 54,311 "4" : 21,312 "5" : 17,313 "6" : '4',314 "7" : 1315 }316 }317 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)318 assert not valid319 assert 'Expected "6" field to be int not' in error320 program_enrollment_test = {"2014" :{ "1" : 84,321 "2" : 68,322 "2T" : 8,323 "3" : 54,324 "4" : 21,325 "5" : 17,326 "6" : 4,327 "7" : '1'328 }329 }330 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)331 assert not valid332 assert 'Expected "7" field to be int not' in error333def test_validate_input_invalid_schedule():334 course_enrollment_test = generate_course_enrollment(['CSC225','SENG275'] ,335 ['CSC226'], 336 ['CSC230'], 337 ['202109', '202201', '202205', '202209', '202301'])338 program_enrollment_test = json.load(open('../data/real/programEnrollmentData.json', 'r'))339 schedule_test = [] 340 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)341 assert not valid342 assert 'Expected schedule to be a dict not' in error343 schedule_test = {'mid_summer':[]} 344 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)345 assert not valid346 assert 'Expected "fall", "spring", or "summer" field not' in error347 schedule_test = {'fall':{}} 348 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)349 assert not valid350 assert 'Expected term to be a list not' in error351 schedule_test = {'fall':['offering']} 352 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)353 assert not valid354 assert 'Expected offering to be a dict not' in error355 # offering = {sections':[{'capacity':1015, 'max_capacity':1015}]}356 offering = {'sections':[{'capacity':1015}]}357 schedule_test = {'fall':[offering]} 358 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)359 assert not valid360 assert 'No "course" field in course offering' in error361 offering = {'course':{'code':'CHEM101'}}362 schedule_test = {'fall':[offering]} 363 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)364 assert not valid365 assert 'No "sections" field in course offering' in error366 # offering = {'course':[]367 # 'sections':[{'capacity':1015, 'max_capacity':1015}]368 # }369 offering = {'course':[],370 'sections':[{'capacity':1015}]371 }372 schedule_test = {'fall':[offering]} 373 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)374 assert not valid375 assert 'Expected offerings "course" field to be a dict not' in error376 offering = {'course':{'code':'CHEM101'},377 'sections':{}378 }379 schedule_test = {'fall':[offering]} 380 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)381 assert not valid382 assert 'Expected offerings "sections" field to be a list' in error383 offering = {'course':{},384 'sections':[]385 }386 schedule_test = {'fall':[offering]} 387 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)388 assert not valid389 assert 'Expected "code" field in course' in error390 offering = {'course':{'code':100},391 'sections':[]}392 schedule_test = {'fall':[offering]} 393 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)394 assert not valid395 assert 'Expected "code" field to be a string not' in error396 offering = {'course':{'code':'CHEM101'},397 'sections':['section']398 }399 schedule_test = {'fall':[offering]} 400 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)401 assert not valid402 assert 'Expected section to be a dict not' in error403 offering = {'course':{'code':'CHEM101'},404 'sections':[{}]405 }406 schedule_test = {'fall':[offering]} 407 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)408 assert not valid409 assert 'Expected "capacity" field to be in section' in error410 # offering = {'course':{'code':'CHEM101'}411 # 'sections':[{'capacity':1015}]412 # }413 # schedule_test = {'fall':[offering]} 414 # valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)415 # assert not valid416 # assert 'Expected "max_capacity" field to be in section' in error417 offering = {'course':{'code':'CHEM101'},418 'sections':[{'capacity':'1015'}]419 }420 schedule_test = {'fall':[offering]} 421 valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)422 assert not valid423 assert 'Expected capacity to be a int not' in error424 # offering = {'course':{'code':'CHEM101'}425 # 'sections':[{'capacity':'1015', 'max_capacity':'1015'}]426 # }427 # schedule_test = {'fall':[offering]} 428 # valid, error = preprocessor.validate_inputs(course_enrollment_test, program_enrollment_test, schedule_test)429 # assert not valid430 # assert 'Expected max_capacity to be a int not' in error431 432def test_max_capacity():433 schedule_test = json.load(open('../data/mock/mockSchedule3.json', 'r'))434 course_enrollment_test = json.load(open('../data/mock/mockHistoricCourseData.json', 'r'))435 data = preprocessor.pre_process(course_enrollment_test, schedule_test)436 assert data == {'CSC225-F': {'data': [250, 250, 250, 750], 'approach': 0, 'capacity': 0},437 'CSC226-F': {'data': [250, 250, 750, 250], 'approach': 0, 'capacity': 0},438 'CSC391-F': {'data': [0, 0, 0, 0], 'approach': 0, 'capacity': 60},439 'CSC320-SP': {'data': [250, 250, 250, 500], 'approach': 0, 'capacity': 0},440 'CSC360-SU': {'data': [250, 750, 250, 250], 'approach': 0, 'capacity': 0},441 'CSC370-SU': {'data': None, 'approach': 0, 'capacity': 100},442 'CSC381-SU': {'data': [0,0,0,0], 'approach': 0, 'capacity': 50}...

Full Screen

Full Screen

test_prototypes.py

Source:test_prototypes.py Github

copy

Full Screen

...16 param.prototype = rlist(rint(0))17 params.inputs = {"a": param}18 input = rlist(rint(1))19 inputs = {"a": input}20 assert "" == validate_inputs(params, inputs)21 def testRListRList(self):22 params = omero.grid.JobParams()23 param = omero.grid.Param()24 param.prototype = rlist(rlist())25 params.inputs = {"a": param}26 input = rlist(rlist(rint(1), rstring("a")))27 inputs = {"a": input}28 assert "" == validate_inputs(params, inputs)29 def testRListRListRString(self):30 params = omero.grid.JobParams()31 param = omero.grid.Param()32 param.prototype = rlist(rlist(rstring("")))33 params.inputs = {"a": param}34 input = rlist(rlist(rstring("a")))35 inputs = {"a": input}36 assert "" == validate_inputs(params, inputs)37 input.val[0].val.insert(0, rint(1))38 assert not "" == validate_inputs(params, inputs)39 # Nested maps40 def testRMapRInt(self):41 params = omero.grid.JobParams()42 param = omero.grid.Param()43 param.prototype = rmap({"b": rint(0)})44 params.inputs = {"a": param}45 input = rmap({"b": rint(1)})46 inputs = {"a": input}47 assert "" == validate_inputs(params, inputs)48 def testRMapRMap(self):49 params = omero.grid.JobParams()50 param = omero.grid.Param()51 param.prototype = rmap({"b": rmap({})})52 params.inputs = {"a": param}53 input = rmap({"b": rmap({"l": rlong(0)})})54 inputs = {"a": input}55 assert "" == validate_inputs(params, inputs)56 def testRMapRMapRInt(self):57 params = omero.grid.JobParams()58 param = omero.grid.Param()59 param.prototype = rmap({"b": rmap({"c": rint(0)})})60 params.inputs = {"a": param}61 input = rmap({"b": rmap({"c": rint(1)})})62 inputs = {"a": input}63 assert "" == validate_inputs(params, inputs)64 # Other65 def testAllParametersChecked(self):66 params = omero.grid.JobParams()67 param = omero.grid.Param()68 param.prototype = rlist(rstring(""))69 params.inputs = {"a": param}70 input = rlist(rstring("foo"), rint(1))71 inputs = {"a": input}72 assert not "" == validate_inputs(params, inputs)73 # Bugs74 def testTicket2323Min(self):75 params = omero.grid.JobParams()76 # Copied from integration/scripts.py:testUploadOfficialScripts77 param = Long('longParam', True, description='theDesc', min=long(1),78 max=long(10), values=[rlong(5)])79 assert 1 == param.min.getValue(), \80 "Min value not correct:" + str(param.min)81 assert 10 == param.max.getValue(), \82 "Max value not correct:" + str(param.max)83 assert 5 == param.values.getValue()[0].getValue(), \84 "First option value not correct:" + str(param.values)85 params.inputs = {"a": param}86 inputs = {"a": rlong(5)}87 errors = validate_inputs(params, inputs)88 assert "" == errors, errors89 def testTicket2323List(self):90 param = List('listParam', True, description='theDesc',91 values=[rlong(5)])...

Full Screen

Full Screen

test_functions.py

Source:test_functions.py Github

copy

Full Screen

...47 ew = {48 "policy": {"errors": {}, "warnings": {}},49 "behavior": {"errors": {}, "warnings": {}},50 }51 res = functions.validate_inputs(52 {"data_source": "CPS", "year": 2013}, {"policy": {}, "behavior": {}}, ew53 )54 assert res["errors_warnings"]["policy"]["errors"].get("year")55class TestFunctions1(CoreTestFunctions):56 get_version = functions.get_version57 get_inputs = functions.get_inputs58 validate_inputs = functions.validate_inputs59 run_model = functions.run_model60 ok_adjustment = OK_ADJUSTMENT61 bad_adjustment = BAD_ADJUSTMENT62class TestFunctions2(CoreTestFunctions):63 get_version = functions.get_version64 get_inputs = functions.get_inputs65 validate_inputs = functions.validate_inputs...

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