How to use generate method in storybook-root

Best JavaScript code snippet using storybook-root

generate_data_test.py

Source:generate_data_test.py Github

copy

Full Screen

1"""2Unit tests for the generate_data module.3@author: nestep4@date: March 20, 20145"""6import datetime7import os8import data_generation.config.cfg as sbac_config9import generate_data as generate_data10import sbac_data_generation.generators.assessment as asmt_gen11import sbac_data_generation.generators.hierarchy as hier_gen12import sbac_data_generation.generators.population as pop_gen13from data_generation.util.id_gen import IDGen14from nose.tools import assert_raises15ID_GEN = IDGen()16def setup_module():17 # Verify output directory exists (some tested methods will write to disk)18 if not os.path.exists(generate_data.OUT_PATH_ROOT):19 os.makedirs(generate_data.OUT_PATH_ROOT)20def test_set_configuration_exception():21 assert_raises(ValueError, generate_data.assign_configuration_options, 'Unknown', 'North Carolina', 'NC',22 'typical_1')23def test_set_configuration_state():24 # Set the configuration25 generate_data.assign_configuration_options('regular', 'North Carolina', 'NC', 'typical_1')26 # Tests27 assert generate_data.STATES[0]['name'] == 'North Carolina'28 assert generate_data.STATES[0]['code'] == 'NC'29 assert generate_data.STATES[0]['type'] == 'typical_1'30def test_set_configuration_regular():31 # Set the configuration32 generate_data.assign_configuration_options('regular', 'North Carolina', 'NC', 'typical_1')33 # Tests34 assert len(generate_data.YEARS) == 335 assert 2015 in generate_data.YEARS36 assert 2016 in generate_data.YEARS37 assert 2017 in generate_data.YEARS38 assert len(generate_data.ASMT_YEARS) == 339 assert 2015 in generate_data.ASMT_YEARS40 assert 2016 in generate_data.ASMT_YEARS41 assert 2017 in generate_data.ASMT_YEARS42 assert len(generate_data.INTERIM_ASMT_PERIODS) == 343 assert 'Fall' in generate_data.INTERIM_ASMT_PERIODS44 assert 'Winter' in generate_data.INTERIM_ASMT_PERIODS45 assert 'Spring' in generate_data.INTERIM_ASMT_PERIODS46 assert generate_data.NUMBER_REGISTRATION_SYSTEMS == 147def test_create_assessment_object():48 asmt = generate_data.create_assessment_object('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN, generate_item_level=False)49 assert asmt.asmt_type == 'SUMMATIVE'50 assert asmt.subject == 'ELA'51def test_create_assessment_object_summative():52 asmt = generate_data.create_assessment_object('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN, generate_item_level=False)53 assert asmt.period_year == 201554 assert asmt.period == 'Spring 2015'55 assert asmt.effective_date == datetime.date(2015, 5, 15)56 assert asmt.from_date == datetime.date(2015, 5, 15)57 assert asmt.to_date == datetime.date(9999, 12, 31)58def test_create_assessment_object_interim_fall():59 asmt = generate_data.create_assessment_object('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN,60 generate_item_level=False)61 assert asmt.period_year == 201562 assert asmt.period == 'Fall 2014'63 assert asmt.effective_date == datetime.date(2014, 9, 15)64 assert asmt.from_date == datetime.date(2014, 9, 15)65 assert asmt.to_date == datetime.date(9999, 12, 31)66def test_create_assessment_object_interim_winter():67 asmt = generate_data.create_assessment_object('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN,68 generate_item_level=False)69 assert asmt.period_year == 201570 assert asmt.period == 'Winter 2014'71 assert asmt.effective_date == datetime.date(2014, 12, 15)72 assert asmt.from_date == datetime.date(2014, 12, 15)73 assert asmt.to_date == datetime.date(9999, 12, 31)74def test_create_assessment_object_interim_spring():75 asmt = generate_data.create_assessment_object('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN,76 generate_item_level=False)77 assert asmt.period_year == 201578 assert asmt.period == 'Spring 2015'79 assert asmt.effective_date == datetime.date(2015, 3, 15)80 assert asmt.from_date == datetime.date(2015, 3, 15)81 assert asmt.to_date == datetime.date(9999, 12, 31)82def test_create_assessment_object_item_data():83 asmt = generate_data.create_assessment_object('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN,84 generate_item_level=True)85 assert len(asmt.item_bank) == sbac_config.ASMT_ITEM_BANK_SIZE86def test_create_assessment_object_no_item_data():87 asmt = generate_data.create_assessment_object('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN,88 generate_item_level=False)89 assert len(asmt.item_bank) == 090def test_create_assessment_outcome_object_item_data():91 # Create objects92 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)93 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)94 district = hier_gen.generate_district('Small Average', state, ID_GEN)95 school = hier_gen.generate_school('Elementary School', district, ID_GEN)96 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)97 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)98 outcomes = {}99 # Create outcomes100 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=0,101 retake_rate=0, delete_rate=0, update_rate=0,102 generate_item_level=True)103 # Tests104 assert len(outcomes) == 1105 assert len(outcomes[asmt.guid_sr][0].item_level_data) == sbac_config.ITEMS_PER_ASMT106def test_create_assessment_outcome_object_skipped():107 # Create objects108 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)109 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)110 district = hier_gen.generate_district('Small Average', state, ID_GEN)111 school = hier_gen.generate_school('Elementary School', district, ID_GEN)112 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)113 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)114 outcomes = {}115 # Create outcomes116 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=1,117 retake_rate=0, delete_rate=0, update_rate=0,118 generate_item_level=False)119 # Tests120 assert len(outcomes) == 0121def test_create_assessment_outcome_object_one_active_result():122 # Create objects123 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)124 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)125 district = hier_gen.generate_district('Small Average', state, ID_GEN)126 school = hier_gen.generate_school('Elementary School', district, ID_GEN)127 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)128 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)129 outcomes = {}130 # Create outcomes131 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=0,132 retake_rate=0, delete_rate=0, update_rate=0)133 # Tests134 assert len(outcomes) == 1135 assert outcomes[asmt.guid_sr][0].result_status == 'C'136 assert outcomes[asmt.guid_sr][0].date_taken == datetime.date(2015, 5, 15)137def test_create_assessment_outcome_object_retake_results():138 # Create objects139 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)140 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)141 district = hier_gen.generate_district('Small Average', state, ID_GEN)142 school = hier_gen.generate_school('Elementary School', district, ID_GEN)143 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)144 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)145 outcomes = {}146 # Create outcomes147 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=0,148 retake_rate=1, delete_rate=0, update_rate=0)149 # Tests150 assert len(outcomes) == 1151 assert outcomes[asmt.guid_sr][0].result_status == 'I'152 assert outcomes[asmt.guid_sr][0].date_taken == datetime.date(2015, 5, 15)153 assert outcomes[asmt.guid_sr][1].result_status == 'C'154 assert outcomes[asmt.guid_sr][1].date_taken == datetime.date(2015, 5, 20)155def test_create_assessment_outcome_object_one_deleted_result():156 # Create objects157 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)158 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)159 district = hier_gen.generate_district('Small Average', state, ID_GEN)160 school = hier_gen.generate_school('Elementary School', district, ID_GEN)161 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)162 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)163 outcomes = {}164 # Create outcomes165 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=0,166 retake_rate=0, delete_rate=1, update_rate=0)167 # Tests168 assert len(outcomes) == 1169 assert outcomes[asmt.guid_sr][0].result_status == 'D'170 assert outcomes[asmt.guid_sr][0].date_taken == datetime.date(2015, 5, 15)171def test_create_assessment_outcome_object_update_no_second_delete_results():172 # Create objects173 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)174 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)175 district = hier_gen.generate_district('Small Average', state, ID_GEN)176 school = hier_gen.generate_school('Elementary School', district, ID_GEN)177 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)178 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)179 outcomes = {}180 # Create outcomes181 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=0,182 retake_rate=0, delete_rate=0, update_rate=1)183 # Tests184 assert len(outcomes) == 1185 assert outcomes[asmt.guid_sr][0].result_status == 'D'186 assert outcomes[asmt.guid_sr][0].date_taken == datetime.date(2015, 5, 15)187 assert outcomes[asmt.guid_sr][1].result_status == 'C'188 assert outcomes[asmt.guid_sr][1].date_taken == datetime.date(2015, 5, 15)189def test_create_assessment_outcome_object_update_second_delete_results():190 # Create objects191 asmt = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)192 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)193 district = hier_gen.generate_district('Small Average', state, ID_GEN)194 school = hier_gen.generate_school('Elementary School', district, ID_GEN)195 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)196 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)197 outcomes = {}198 # Create outcomes199 generate_data.create_assessment_outcome_object(student, asmt, inst_hier, ID_GEN, outcomes, skip_rate=0,200 retake_rate=0, delete_rate=1, update_rate=1)201 # Tests202 assert len(outcomes) == 1203 assert outcomes[asmt.guid_sr][0].result_status == 'D'204 assert outcomes[asmt.guid_sr][0].date_taken == datetime.date(2015, 5, 15)205 assert outcomes[asmt.guid_sr][1].result_status == 'D'206 assert outcomes[asmt.guid_sr][1].date_taken == datetime.date(2015, 5, 15)207def test_create_assessment_outcome_objects_no_interims_skipped():208 # Create objects209 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)210 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)211 district = hier_gen.generate_district('Small Average', state, ID_GEN)212 school = hier_gen.generate_school('Elementary School', district, ID_GEN)213 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)214 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)215 outcomes = {}216 # Create outcomes217 generate_data.create_assessment_outcome_objects(student, asmt_summ, [], inst_hier, ID_GEN, outcomes,218 skip_rate=1, retake_rate=0, delete_rate=0, update_rate=0,219 generate_item_level=False)220 # Tests221 assert len(outcomes) == 0222def test_create_assessment_outcome_objects_no_interims_one_active_result():223 # Create objects224 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)225 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)226 district = hier_gen.generate_district('Small Average', state, ID_GEN)227 school = hier_gen.generate_school('Elementary School', district, ID_GEN)228 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)229 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)230 outcomes = {}231 # Create outcomes232 generate_data.create_assessment_outcome_objects(student, asmt_summ, [], inst_hier, ID_GEN, outcomes,233 skip_rate=0, retake_rate=0, delete_rate=0, update_rate=0,234 generate_item_level=False)235 # Tests236 assert len(outcomes) == 1237 assert outcomes[asmt_summ.guid_sr][0].result_status == 'C'238 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)239def test_create_assessment_outcome_objects_no_interims_retake_results():240 # Create objects241 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)242 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)243 district = hier_gen.generate_district('Small Average', state, ID_GEN)244 school = hier_gen.generate_school('Elementary School', district, ID_GEN)245 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)246 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)247 outcomes = {}248 # Create outcomes249 generate_data.create_assessment_outcome_objects(student, asmt_summ, [], inst_hier, ID_GEN, outcomes,250 skip_rate=0, retake_rate=1, delete_rate=0, update_rate=0,251 generate_item_level=False)252 # Tests253 assert len(outcomes) == 1254 assert outcomes[asmt_summ.guid_sr][0].result_status == 'I'255 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)256 assert outcomes[asmt_summ.guid_sr][1].result_status == 'C'257 assert outcomes[asmt_summ.guid_sr][1].date_taken == datetime.date(2015, 5, 20)258def test_create_assessment_outcome_objects_no_interim_one_deleted_result():259 # Create objects260 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)261 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)262 district = hier_gen.generate_district('Small Average', state, ID_GEN)263 school = hier_gen.generate_school('Elementary School', district, ID_GEN)264 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)265 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)266 outcomes = {}267 # Create outcomes268 generate_data.create_assessment_outcome_objects(student, asmt_summ, [], inst_hier, ID_GEN, outcomes,269 skip_rate=0, retake_rate=0, delete_rate=1, update_rate=0,270 generate_item_level=False)271 # Tests272 assert len(outcomes) == 1273 assert outcomes[asmt_summ.guid_sr][0].result_status == 'D'274 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)275def test_create_assessment_outcome_objects_no_interim_update_no_second_delete_results():276 # Create objects277 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)278 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)279 district = hier_gen.generate_district('Small Average', state, ID_GEN)280 school = hier_gen.generate_school('Elementary School', district, ID_GEN)281 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)282 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)283 outcomes = {}284 # Create outcomes285 generate_data.create_assessment_outcome_objects(student, asmt_summ, [], inst_hier, ID_GEN, outcomes,286 skip_rate=0, retake_rate=0, delete_rate=0, update_rate=1,287 generate_item_level=False)288 # Tests289 assert len(outcomes) == 1290 assert outcomes[asmt_summ.guid_sr][0].result_status == 'D'291 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)292 assert outcomes[asmt_summ.guid_sr][1].result_status == 'C'293 assert outcomes[asmt_summ.guid_sr][1].date_taken == datetime.date(2015, 5, 15)294def test_create_assessment_outcome_objects_no_interim_update_second_delete_results():295 # Create objects296 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)297 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)298 district = hier_gen.generate_district('Small Average', state, ID_GEN)299 school = hier_gen.generate_school('Elementary School', district, ID_GEN)300 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)301 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)302 outcomes = {}303 # Create outcomes304 generate_data.create_assessment_outcome_objects(student, asmt_summ, [], inst_hier, ID_GEN, outcomes,305 skip_rate=0, retake_rate=0, delete_rate=1, update_rate=1,306 generate_item_level=False)307 # Tests308 assert len(outcomes) == 1309 assert outcomes[asmt_summ.guid_sr][0].result_status == 'D'310 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)311 assert outcomes[asmt_summ.guid_sr][1].result_status == 'D'312 assert outcomes[asmt_summ.guid_sr][1].date_taken == datetime.date(2015, 5, 15)313def test_create_assessment_outcome_objects_interims_skipped():314 # Create objects315 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)316 interim_asmts = [asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN),317 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN),318 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN)]319 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)320 district = hier_gen.generate_district('Small Average', state, ID_GEN)321 school = hier_gen.generate_school('Elementary School', district, ID_GEN)322 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)323 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)324 outcomes = {}325 # Create outcomes326 generate_data.create_assessment_outcome_objects(student, asmt_summ, interim_asmts, inst_hier, ID_GEN,327 outcomes, skip_rate=1, retake_rate=0, delete_rate=0, update_rate=0,328 generate_item_level=False)329 # Tests330 assert len(outcomes) == 0331def test_create_assessment_outcome_objects_interims_one_active_result():332 # Create objects333 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)334 interim_asmts = [asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN),335 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN),336 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN)]337 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)338 district = hier_gen.generate_district('Small Average', state, ID_GEN)339 school = hier_gen.generate_school('Elementary School', district, ID_GEN)340 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)341 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)342 outcomes = {}343 # Create outcomes344 generate_data.create_assessment_outcome_objects(student, asmt_summ, interim_asmts, inst_hier, ID_GEN,345 outcomes, skip_rate=0, retake_rate=0, delete_rate=0, update_rate=0,346 generate_item_level=False)347 # Tests348 assert len(outcomes) == 4349 assert outcomes[asmt_summ.guid_sr][0].assessment.asmt_type == 'SUMMATIVE'350 assert outcomes[asmt_summ.guid_sr][0].result_status == 'C'351 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)352 assert outcomes[interim_asmts[0].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'353 assert outcomes[interim_asmts[0].guid_sr][0].result_status == 'C'354 assert outcomes[interim_asmts[0].guid_sr][0].date_taken == datetime.date(2014, 9, 15)355 assert outcomes[interim_asmts[1].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'356 assert outcomes[interim_asmts[1].guid_sr][0].result_status == 'C'357 assert outcomes[interim_asmts[1].guid_sr][0].date_taken == datetime.date(2014, 12, 15)358 assert outcomes[interim_asmts[2].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'359 assert outcomes[interim_asmts[2].guid_sr][0].result_status == 'C'360 assert outcomes[interim_asmts[2].guid_sr][0].date_taken == datetime.date(2015, 3, 15)361def test_create_assessment_outcome_objects_interims_retake_results():362 # Create objects363 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)364 interim_asmts = [asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN),365 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN),366 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN)]367 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)368 district = hier_gen.generate_district('Small Average', state, ID_GEN)369 school = hier_gen.generate_school('Elementary School', district, ID_GEN)370 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)371 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)372 outcomes = {}373 # Create outcomes374 generate_data.create_assessment_outcome_objects(student, asmt_summ, interim_asmts, inst_hier, ID_GEN,375 outcomes, skip_rate=0, retake_rate=1, delete_rate=0, update_rate=0,376 generate_item_level=False)377 # Tests378 assert len(outcomes) == 4379 assert outcomes[asmt_summ.guid_sr][0].assessment.asmt_type == 'SUMMATIVE'380 assert outcomes[asmt_summ.guid_sr][0].result_status == 'I'381 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)382 assert outcomes[asmt_summ.guid_sr][1].assessment.asmt_type == 'SUMMATIVE'383 assert outcomes[asmt_summ.guid_sr][1].result_status == 'C'384 assert outcomes[asmt_summ.guid_sr][1].date_taken == datetime.date(2015, 5, 20)385 assert outcomes[interim_asmts[0].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'386 assert outcomes[interim_asmts[0].guid_sr][0].result_status == 'I'387 assert outcomes[interim_asmts[0].guid_sr][0].date_taken == datetime.date(2014, 9, 15)388 assert outcomes[interim_asmts[0].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'389 assert outcomes[interim_asmts[0].guid_sr][1].result_status == 'C'390 assert outcomes[interim_asmts[0].guid_sr][1].date_taken == datetime.date(2014, 9, 20)391 assert outcomes[interim_asmts[1].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'392 assert outcomes[interim_asmts[1].guid_sr][0].result_status == 'I'393 assert outcomes[interim_asmts[1].guid_sr][0].date_taken == datetime.date(2014, 12, 15)394 assert outcomes[interim_asmts[1].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'395 assert outcomes[interim_asmts[1].guid_sr][1].result_status == 'C'396 assert outcomes[interim_asmts[1].guid_sr][1].date_taken == datetime.date(2014, 12, 20)397 assert outcomes[interim_asmts[2].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'398 assert outcomes[interim_asmts[2].guid_sr][0].result_status == 'I'399 assert outcomes[interim_asmts[2].guid_sr][0].date_taken == datetime.date(2015, 3, 15)400 assert outcomes[interim_asmts[2].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'401 assert outcomes[interim_asmts[2].guid_sr][1].result_status == 'C'402 assert outcomes[interim_asmts[2].guid_sr][1].date_taken == datetime.date(2015, 3, 20)403def test_create_assessment_outcome_objects_interim_one_deleted_result():404 # Create objects405 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)406 interim_asmts = [asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN),407 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN),408 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN)]409 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)410 district = hier_gen.generate_district('Small Average', state, ID_GEN)411 school = hier_gen.generate_school('Elementary School', district, ID_GEN)412 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)413 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)414 outcomes = {}415 # Create outcomes416 generate_data.create_assessment_outcome_objects(student, asmt_summ, interim_asmts, inst_hier, ID_GEN,417 outcomes, skip_rate=0, retake_rate=0, delete_rate=1, update_rate=0)418 # Tests419 assert len(outcomes) == 4420 assert outcomes[asmt_summ.guid_sr][0].assessment.asmt_type == 'SUMMATIVE'421 assert outcomes[asmt_summ.guid_sr][0].result_status == 'D'422 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)423 assert outcomes[interim_asmts[0].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'424 assert outcomes[interim_asmts[0].guid_sr][0].result_status == 'D'425 assert outcomes[interim_asmts[0].guid_sr][0].date_taken == datetime.date(2014, 9, 15)426 assert outcomes[interim_asmts[1].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'427 assert outcomes[interim_asmts[1].guid_sr][0].result_status == 'D'428 assert outcomes[interim_asmts[1].guid_sr][0].date_taken == datetime.date(2014, 12, 15)429 assert outcomes[interim_asmts[2].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'430 assert outcomes[interim_asmts[2].guid_sr][0].result_status == 'D'431 assert outcomes[interim_asmts[2].guid_sr][0].date_taken == datetime.date(2015, 3, 15)432def test_create_assessment_outcome_objects_interim_update_no_second_delete_results():433 # Create objects434 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)435 interim_asmts = [asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN),436 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN),437 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN)]438 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)439 district = hier_gen.generate_district('Small Average', state, ID_GEN)440 school = hier_gen.generate_school('Elementary School', district, ID_GEN)441 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)442 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)443 outcomes = {}444 # Create outcomes445 generate_data.create_assessment_outcome_objects(student, asmt_summ, interim_asmts, inst_hier, ID_GEN,446 outcomes, skip_rate=0, retake_rate=0, delete_rate=0, update_rate=1,447 generate_item_level=False)448 # Tests449 assert len(outcomes) == 4450 assert outcomes[asmt_summ.guid_sr][0].assessment.asmt_type == 'SUMMATIVE'451 assert outcomes[asmt_summ.guid_sr][0].result_status == 'D'452 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)453 assert outcomes[asmt_summ.guid_sr][1].assessment.asmt_type == 'SUMMATIVE'454 assert outcomes[asmt_summ.guid_sr][1].result_status == 'C'455 assert outcomes[asmt_summ.guid_sr][1].date_taken == datetime.date(2015, 5, 15)456 assert outcomes[interim_asmts[0].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'457 assert outcomes[interim_asmts[0].guid_sr][0].result_status == 'D'458 assert outcomes[interim_asmts[0].guid_sr][0].date_taken == datetime.date(2014, 9, 15)459 assert outcomes[interim_asmts[0].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'460 assert outcomes[interim_asmts[0].guid_sr][1].result_status == 'C'461 assert outcomes[interim_asmts[0].guid_sr][1].date_taken == datetime.date(2014, 9, 15)462 assert outcomes[interim_asmts[1].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'463 assert outcomes[interim_asmts[1].guid_sr][0].result_status == 'D'464 assert outcomes[interim_asmts[1].guid_sr][0].date_taken == datetime.date(2014, 12, 15)465 assert outcomes[interim_asmts[1].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'466 assert outcomes[interim_asmts[1].guid_sr][1].result_status == 'C'467 assert outcomes[interim_asmts[1].guid_sr][1].date_taken == datetime.date(2014, 12, 15)468 assert outcomes[interim_asmts[2].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'469 assert outcomes[interim_asmts[2].guid_sr][0].result_status == 'D'470 assert outcomes[interim_asmts[2].guid_sr][0].date_taken == datetime.date(2015, 3, 15)471 assert outcomes[interim_asmts[2].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'472 assert outcomes[interim_asmts[2].guid_sr][1].result_status == 'C'473 assert outcomes[interim_asmts[2].guid_sr][1].date_taken == datetime.date(2015, 3, 15)474def test_create_assessment_outcome_objects_interim_update_second_delete_results():475 # Create objects476 asmt_summ = asmt_gen.generate_assessment('SUMMATIVE', 'Spring', 2015, 'ELA', ID_GEN)477 interim_asmts = [asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Fall', 2015, 'ELA', ID_GEN),478 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Winter', 2015, 'ELA', ID_GEN),479 asmt_gen.generate_assessment('INTERIM COMPREHENSIVE', 'Spring', 2015, 'ELA', ID_GEN)]480 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)481 district = hier_gen.generate_district('Small Average', state, ID_GEN)482 school = hier_gen.generate_school('Elementary School', district, ID_GEN)483 student = pop_gen.generate_student(school, 3, ID_GEN, 2015)484 inst_hier = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)485 outcomes = {}486 # Create outcomes487 generate_data.create_assessment_outcome_objects(student, asmt_summ, interim_asmts, inst_hier, ID_GEN,488 outcomes, skip_rate=0, retake_rate=0, delete_rate=1, update_rate=1,489 generate_item_level=False)490 # Tests491 assert len(outcomes) == 4492 assert outcomes[asmt_summ.guid_sr][0].assessment.asmt_type == 'SUMMATIVE'493 assert outcomes[asmt_summ.guid_sr][0].result_status == 'D'494 assert outcomes[asmt_summ.guid_sr][0].date_taken == datetime.date(2015, 5, 15)495 assert outcomes[asmt_summ.guid_sr][1].assessment.asmt_type == 'SUMMATIVE'496 assert outcomes[asmt_summ.guid_sr][1].result_status == 'D'497 assert outcomes[asmt_summ.guid_sr][1].date_taken == datetime.date(2015, 5, 15)498 assert outcomes[interim_asmts[0].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'499 assert outcomes[interim_asmts[0].guid_sr][0].result_status == 'D'500 assert outcomes[interim_asmts[0].guid_sr][0].date_taken == datetime.date(2014, 9, 15)501 assert outcomes[interim_asmts[0].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'502 assert outcomes[interim_asmts[0].guid_sr][1].result_status == 'D'503 assert outcomes[interim_asmts[0].guid_sr][1].date_taken == datetime.date(2014, 9, 15)504 assert outcomes[interim_asmts[1].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'505 assert outcomes[interim_asmts[1].guid_sr][0].result_status == 'D'506 assert outcomes[interim_asmts[1].guid_sr][0].date_taken == datetime.date(2014, 12, 15)507 assert outcomes[interim_asmts[1].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'508 assert outcomes[interim_asmts[1].guid_sr][1].result_status == 'D'509 assert outcomes[interim_asmts[1].guid_sr][1].date_taken == datetime.date(2014, 12, 15)510 assert outcomes[interim_asmts[2].guid_sr][0].assessment.asmt_type == 'INTERIM COMPREHENSIVE'511 assert outcomes[interim_asmts[2].guid_sr][0].result_status == 'D'512 assert outcomes[interim_asmts[2].guid_sr][0].date_taken == datetime.date(2015, 3, 15)513 assert outcomes[interim_asmts[2].guid_sr][1].assessment.asmt_type == 'INTERIM COMPREHENSIVE'514 assert outcomes[interim_asmts[2].guid_sr][1].result_status == 'D'...

Full Screen

Full Screen

texture_builtins.py

Source:texture_builtins.py Github

copy

Full Screen

1#!/usr/bin/python2import sys3import StringIO4# Bitfield constants for the 'variant' argument to generate_sigs5Proj = 16Offset = 27Single = 48def vec_type(g, size):9 if size == 1:10 if g == "i":11 return "int"12 elif g == "u":13 return "uint"14 return "float"15 return g + "vec" + str(size)16# Get the sampler dimension - i.e. sampler3D gives 317def get_sampler_dim(sampler_type):18 if sampler_type[0].isdigit():19 sampler_dim = int(sampler_type[0])20 elif sampler_type.startswith("Cube"):21 sampler_dim = 322 elif sampler_type == "ExternalOES":23 sampler_dim = 224 elif sampler_type == "Buffer":25 sampler_dim = 126 else:27 assert False ("coord_dim: invalid sampler_type: " + sampler_type)28 return sampler_dim29# Get the coordinate dimension for a given sampler type.30# Array samplers also get +1 here since the layer is really an extra coordinate31def get_coord_dim(sampler_type):32 coord_dim = get_sampler_dim(sampler_type)33 if sampler_type.find("Array") != -1:34 coord_dim += 135 return coord_dim36# Get the number of extra vector components (i.e. shadow comparitor)37def get_extra_dim(sampler_type, use_proj, unused_fields):38 extra_dim = unused_fields39 if sampler_type.find("Shadow") != -1:40 extra_dim += 141 if use_proj:42 extra_dim += 143 return extra_dim44def get_txs_dim(sampler_type):45 if sampler_type.startswith("Cube"):46 return 247 return get_coord_dim(sampler_type)48def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):49 coord_dim = get_coord_dim(sampler_type)50 extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields)51 sampler_dim = get_sampler_dim(sampler_type)52 if variant & Single:53 return_type = "float"54 elif tex_inst == "txs":55 return_type = vec_type("i", get_txs_dim(sampler_type))56 else:57 return_type = g + "vec4"58 # Print parameters59 print " (signature", return_type60 print " (parameters"61 print " (declare (in) " + g + "sampler" + sampler_type + " sampler)",62 if tex_inst != "txs":63 print "\n (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",64 if tex_inst == "txl":65 print "\n (declare (in) float lod)",66 elif ((tex_inst == "txf" or tex_inst == "txs") and "Buffer" not in sampler_type and "Rect" not in sampler_type):67 print "\n (declare (in) int lod)",68 elif tex_inst == "txd":69 grad_type = vec_type("", sampler_dim)70 print "\n (declare (in) " + grad_type + " dPdx)",71 print "\n (declare (in) " + grad_type + " dPdy)",72 if variant & Offset:73 print "\n (declare (const_in) " + vec_type("i", sampler_dim) + " offset)",74 if tex_inst == "txb":75 print "\n (declare (in) float bias)",76 print ")\n ((return (" + tex_inst, return_type, "(var_ref sampler)",77 if tex_inst != "txs":78 # Coordinate79 if extra_dim > 0:80 print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))",81 else:82 print "(var_ref P)",83 if variant & Offset:84 print "(var_ref offset)",85 else:86 print "0",87 if tex_inst != "txf" and tex_inst != "txs":88 # Projective divisor89 if variant & Proj:90 print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))",91 else:92 print "1",93 # Shadow comparitor94 if sampler_type == "2DArrayShadow" or sampler_type == "CubeShadow": # a special case:95 print "(swiz w (var_ref P))", # ...array layer is z; shadow is w96 elif sampler_type.endswith("Shadow"):97 print "(swiz z (var_ref P))",98 else:99 print "()",100 # Bias/explicit LOD/gradient:101 if tex_inst == "txb":102 print "(var_ref bias)",103 elif tex_inst == "txs" or tex_inst == "txf":104 if "Rect" not in sampler_type and "Buffer" not in sampler_type:105 print "(var_ref lod)",106 else:107 print "(constant int (0))"108 elif tex_inst == "txl":109 print "(var_ref lod)",110 elif tex_inst == "txd":111 print "((var_ref dPdx) (var_ref dPdy))",112 print "))))\n"113def generate_fiu_sigs(tex_inst, sampler_type, variant = 0, unused_fields = 0):114 generate_sigs("", tex_inst, sampler_type, variant, unused_fields)115 generate_sigs("i", tex_inst, sampler_type, variant, unused_fields)116 generate_sigs("u", tex_inst, sampler_type, variant, unused_fields)117def start_function(name):118 sys.stdout = StringIO.StringIO()119 print "((function " + name120def end_function(fs, name):121 print "))"122 fs[name] = sys.stdout.getvalue();123 sys.stdout.close()124# Generate all the functions and store them in the supplied dictionary.125# This is better than writing them to actual files since they should never be126# edited; it'd also be easy to confuse them with the many hand-generated files.127#128# Takes a dictionary as an argument.129def generate_texture_functions(fs):130 start_function("textureSize")131 generate_fiu_sigs("txs", "1D")132 generate_fiu_sigs("txs", "2D")133 generate_fiu_sigs("txs", "3D")134 generate_fiu_sigs("txs", "Cube")135 generate_fiu_sigs("txs", "1DArray")136 generate_fiu_sigs("txs", "2DArray")137 generate_sigs("", "txs", "1DShadow")138 generate_sigs("", "txs", "2DShadow")139 generate_sigs("", "txs", "CubeShadow")140 generate_sigs("", "txs", "1DArrayShadow")141 generate_sigs("", "txs", "2DArrayShadow")142 generate_fiu_sigs("txs", "2DRect")143 generate_sigs("", "txs", "2DRectShadow")144 generate_fiu_sigs("txs", "Buffer")145 end_function(fs, "textureSize")146 start_function("texture")147 generate_fiu_sigs("tex", "1D")148 generate_fiu_sigs("tex", "2D")149 generate_fiu_sigs("tex", "3D")150 generate_fiu_sigs("tex", "Cube")151 generate_fiu_sigs("tex", "1DArray")152 generate_fiu_sigs("tex", "2DArray")153 generate_sigs("", "tex", "1DShadow", Single, 1);154 generate_sigs("", "tex", "2DShadow", Single);155 generate_sigs("", "tex", "CubeShadow", Single);156 generate_sigs("", "tex", "1DArrayShadow", Single);157 generate_sigs("", "tex", "2DArrayShadow", Single);158 generate_fiu_sigs("tex", "2DRect")159 generate_sigs("", "tex", "2DRectShadow", Single);160 generate_fiu_sigs("txb", "1D")161 generate_fiu_sigs("txb", "2D")162 generate_fiu_sigs("txb", "3D")163 generate_fiu_sigs("txb", "Cube")164 generate_fiu_sigs("txb", "1DArray")165 generate_fiu_sigs("txb", "2DArray")166 generate_sigs("", "txb", "1DShadow", Single, 1);167 generate_sigs("", "txb", "2DShadow", Single);168 generate_sigs("", "txb", "CubeShadow", Single);169 generate_sigs("", "txb", "1DArrayShadow", Single);170 generate_sigs("", "txb", "2DArrayShadow", Single);171 end_function(fs, "texture")172 start_function("textureProj")173 generate_fiu_sigs("tex", "1D", Proj)174 generate_fiu_sigs("tex", "1D", Proj, 2)175 generate_fiu_sigs("tex", "2D", Proj)176 generate_fiu_sigs("tex", "2D", Proj, 1)177 generate_fiu_sigs("tex", "3D", Proj)178 generate_sigs("", "tex", "1DShadow", Proj | Single, 1);179 generate_sigs("", "tex", "2DShadow", Proj | Single);180 generate_fiu_sigs("tex", "2DRect", Proj)181 generate_fiu_sigs("tex", "2DRect", Proj, 1)182 generate_sigs("", "tex", "2DRectShadow", Proj | Single);183 generate_fiu_sigs("txb", "1D", Proj)184 generate_fiu_sigs("txb", "1D", Proj, 2)185 generate_fiu_sigs("txb", "2D", Proj)186 generate_fiu_sigs("txb", "2D", Proj, 1)187 generate_fiu_sigs("txb", "3D", Proj)188 generate_sigs("", "txb", "1DShadow", Proj | Single, 1);189 generate_sigs("", "txb", "2DShadow", Proj | Single);190 end_function(fs, "textureProj")191 start_function("textureLod")192 generate_fiu_sigs("txl", "1D")193 generate_fiu_sigs("txl", "2D")194 generate_fiu_sigs("txl", "3D")195 generate_fiu_sigs("txl", "Cube")196 generate_fiu_sigs("txl", "1DArray")197 generate_fiu_sigs("txl", "2DArray")198 generate_sigs("", "txl", "1DShadow", Single, 1);199 generate_sigs("", "txl", "2DShadow", Single);200 generate_sigs("", "txl", "1DArrayShadow", Single);201 end_function(fs, "textureLod")202 start_function("textureLodOffset")203 generate_fiu_sigs("txl", "1D", Offset)204 generate_fiu_sigs("txl", "2D", Offset)205 generate_fiu_sigs("txl", "3D", Offset)206 generate_fiu_sigs("txl", "1DArray", Offset)207 generate_fiu_sigs("txl", "2DArray", Offset)208 generate_sigs("", "txl", "1DShadow", Offset | Single, 1);209 generate_sigs("", "txl", "2DShadow", Offset | Single);210 generate_sigs("", "txl", "1DArrayShadow", Offset | Single);211 end_function(fs, "textureLodOffset")212 start_function("textureOffset")213 generate_fiu_sigs("tex", "1D", Offset)214 generate_fiu_sigs("tex", "2D", Offset)215 generate_fiu_sigs("tex", "3D", Offset)216 generate_fiu_sigs("tex", "2DRect", Offset)217 generate_sigs("", "tex", "2DRectShadow", Offset | Single);218 generate_fiu_sigs("tex", "1DArray", Offset)219 generate_fiu_sigs("tex", "2DArray", Offset)220 generate_sigs("", "tex", "1DShadow", Offset | Single, 1);221 generate_sigs("", "tex", "2DShadow", Offset | Single);222 generate_sigs("", "tex", "1DArrayShadow", Offset | Single);223 generate_fiu_sigs("txb", "1D", Offset)224 generate_fiu_sigs("txb", "2D", Offset)225 generate_fiu_sigs("txb", "3D", Offset)226 generate_fiu_sigs("txb", "1DArray", Offset)227 generate_fiu_sigs("txb", "2DArray", Offset)228 generate_sigs("", "txb", "1DShadow", Offset | Single, 1);229 generate_sigs("", "txb", "2DShadow", Offset | Single);230 generate_sigs("", "txb", "1DArrayShadow", Offset | Single);231 end_function(fs, "textureOffset")232 start_function("texelFetch")233 generate_fiu_sigs("txf", "1D")234 generate_fiu_sigs("txf", "2D")235 generate_fiu_sigs("txf", "3D")236 generate_fiu_sigs("txf", "2DRect")237 generate_fiu_sigs("txf", "1DArray")238 generate_fiu_sigs("txf", "2DArray")239 generate_fiu_sigs("txf", "Buffer")240 end_function(fs, "texelFetch")241 start_function("texelFetchOffset")242 generate_fiu_sigs("txf", "1D", Offset)243 generate_fiu_sigs("txf", "2D", Offset)244 generate_fiu_sigs("txf", "3D", Offset)245 generate_fiu_sigs("txf", "2DRect", Offset)246 generate_fiu_sigs("txf", "1DArray", Offset)247 generate_fiu_sigs("txf", "2DArray", Offset)248 end_function(fs, "texelFetchOffset")249 start_function("textureProjOffset")250 generate_fiu_sigs("tex", "1D", Proj | Offset)251 generate_fiu_sigs("tex", "1D", Proj | Offset, 2)252 generate_fiu_sigs("tex", "2D", Proj | Offset)253 generate_fiu_sigs("tex", "2D", Proj | Offset, 1)254 generate_fiu_sigs("tex", "3D", Proj | Offset)255 generate_fiu_sigs("tex", "2DRect", Proj | Offset)256 generate_fiu_sigs("tex", "2DRect", Proj | Offset, 1)257 generate_sigs("", "tex", "2DRectShadow", Proj | Offset | Single);258 generate_sigs("", "tex", "1DShadow", Proj | Offset | Single, 1);259 generate_sigs("", "tex", "2DShadow", Proj | Offset | Single);260 generate_fiu_sigs("txb", "1D", Proj | Offset)261 generate_fiu_sigs("txb", "1D", Proj | Offset, 2)262 generate_fiu_sigs("txb", "2D", Proj | Offset)263 generate_fiu_sigs("txb", "2D", Proj | Offset, 1)264 generate_fiu_sigs("txb", "3D", Proj | Offset)265 generate_sigs("", "txb", "1DShadow", Proj | Offset | Single, 1);266 generate_sigs("", "txb", "2DShadow", Proj | Offset | Single);267 end_function(fs, "textureProjOffset")268 start_function("textureProjLod")269 generate_fiu_sigs("txl", "1D", Proj)270 generate_fiu_sigs("txl", "1D", Proj, 2)271 generate_fiu_sigs("txl", "2D", Proj)272 generate_fiu_sigs("txl", "2D", Proj, 1)273 generate_fiu_sigs("txl", "3D", Proj)274 generate_sigs("", "txl", "1DShadow", Proj | Single, 1);275 generate_sigs("", "txl", "2DShadow", Proj | Single);276 end_function(fs, "textureProjLod")277 start_function("textureProjLodOffset")278 generate_fiu_sigs("txl", "1D", Proj | Offset)279 generate_fiu_sigs("txl", "1D", Proj | Offset, 2)280 generate_fiu_sigs("txl", "2D", Proj | Offset)281 generate_fiu_sigs("txl", "2D", Proj | Offset, 1)282 generate_fiu_sigs("txl", "3D", Proj | Offset)283 generate_sigs("", "txl", "1DShadow", Proj | Offset | Single, 1);284 generate_sigs("", "txl", "2DShadow", Proj | Offset | Single);285 end_function(fs, "textureProjLodOffset")286 start_function("textureGrad")287 generate_fiu_sigs("txd", "1D")288 generate_fiu_sigs("txd", "2D")289 generate_fiu_sigs("txd", "3D")290 generate_fiu_sigs("txd", "Cube")291 generate_fiu_sigs("txd", "1DArray")292 generate_fiu_sigs("txd", "2DArray")293 generate_fiu_sigs("txd", "2DRect")294 generate_sigs("", "txd", "2DRectShadow", Single);295 generate_sigs("", "txd", "1DShadow", Single, 1);296 generate_sigs("", "txd", "2DShadow", Single);297 generate_sigs("", "txd", "CubeShadow", Single);298 generate_sigs("", "txd", "1DArrayShadow", Single);299 generate_sigs("", "txd", "2DArrayShadow", Single);300 end_function(fs, "textureGrad")301 start_function("textureGradOffset")302 generate_fiu_sigs("txd", "1D", Offset)303 generate_fiu_sigs("txd", "2D", Offset)304 generate_fiu_sigs("txd", "3D", Offset)305 generate_fiu_sigs("txd", "2DRect", Offset)306 generate_sigs("", "txd", "2DRectShadow", Offset | Single);307 generate_fiu_sigs("txd", "1DArray", Offset)308 generate_fiu_sigs("txd", "2DArray", Offset)309 generate_sigs("", "txd", "1DShadow", Offset | Single, 1);310 generate_sigs("", "txd", "2DShadow", Offset | Single);311 generate_sigs("", "txd", "1DArrayShadow", Offset | Single);312 generate_sigs("", "txd", "2DArrayShadow", Offset | Single);313 end_function(fs, "textureGradOffset")314 start_function("textureProjGrad")315 generate_fiu_sigs("txd", "1D", Proj)316 generate_fiu_sigs("txd", "1D", Proj, 2)317 generate_fiu_sigs("txd", "2D", Proj)318 generate_fiu_sigs("txd", "2D", Proj, 1)319 generate_fiu_sigs("txd", "3D", Proj)320 generate_fiu_sigs("txd", "2DRect", Proj)321 generate_fiu_sigs("txd", "2DRect", Proj, 1)322 generate_sigs("", "txd", "2DRectShadow", Proj | Single);323 generate_sigs("", "txd", "1DShadow", Proj | Single, 1);324 generate_sigs("", "txd", "2DShadow", Proj | Single);325 end_function(fs, "textureProjGrad")326 start_function("textureProjGradOffset")327 generate_fiu_sigs("txd", "1D", Proj | Offset)328 generate_fiu_sigs("txd", "1D", Proj | Offset, 2)329 generate_fiu_sigs("txd", "2D", Proj | Offset)330 generate_fiu_sigs("txd", "2D", Proj | Offset, 1)331 generate_fiu_sigs("txd", "3D", Proj | Offset)332 generate_fiu_sigs("txd", "2DRect", Proj | Offset)333 generate_fiu_sigs("txd", "2DRect", Proj | Offset, 1)334 generate_sigs("", "txd", "2DRectShadow", Proj | Offset | Single);335 generate_sigs("", "txd", "1DShadow", Proj | Offset | Single, 1);336 generate_sigs("", "txd", "2DShadow", Proj | Offset | Single);337 end_function(fs, "textureProjGradOffset")338 # ARB_texture_rectangle extension339 start_function("texture2DRect")340 generate_sigs("", "tex", "2DRect")341 end_function(fs, "texture2DRect")342 start_function("texture2DRectProj")343 generate_sigs("", "tex", "2DRect", Proj)344 generate_sigs("", "tex", "2DRect", Proj, 1)345 end_function(fs, "texture2DRectProj")346 start_function("shadow2DRect")347 generate_sigs("", "tex", "2DRectShadow")348 end_function(fs, "shadow2DRect")349 start_function("shadow2DRectProj")350 generate_sigs("", "tex", "2DRectShadow", Proj)351 end_function(fs, "shadow2DRectProj")352 # EXT_texture_array extension353 start_function("texture1DArray")354 generate_sigs("", "tex", "1DArray")355 generate_sigs("", "txb", "1DArray")356 end_function(fs, "texture1DArray")357 start_function("texture1DArrayLod")358 generate_sigs("", "txl", "1DArray")359 end_function(fs, "texture1DArrayLod")360 start_function("texture2DArray")361 generate_sigs("", "tex", "2DArray")362 generate_sigs("", "txb", "2DArray")363 end_function(fs, "texture2DArray")364 start_function("texture2DArrayLod")365 generate_sigs("", "txl", "2DArray")366 end_function(fs, "texture2DArrayLod")367 start_function("shadow1DArray")368 generate_sigs("", "tex", "1DArrayShadow")369 generate_sigs("", "txb", "1DArrayShadow")370 end_function(fs, "shadow1DArray")371 start_function("shadow1DArrayLod")372 generate_sigs("", "txl", "1DArrayShadow")373 end_function(fs, "shadow1DArrayLod")374 start_function("shadow2DArray")375 generate_sigs("", "tex", "2DArrayShadow")376 end_function(fs, "shadow2DArray")377 # ARB_shader_texture_lod extension378 start_function("texture1DGradARB")379 generate_fiu_sigs("txd", "1D")380 end_function(fs, "texture1DGradARB")381 start_function("texture2DGradARB")382 generate_fiu_sigs("txd", "2D")383 end_function(fs, "texture2DGradARB")384 start_function("texture3DGradARB")385 generate_fiu_sigs("txd", "3D")386 end_function(fs, "texture3DGradARB")387 start_function("textureCubeGradARB")388 generate_fiu_sigs("txd", "Cube")389 end_function(fs, "textureCubeGradARB")390 start_function("texture1DProjGradARB")391 generate_fiu_sigs("txd", "1D", True)392 generate_fiu_sigs("txd", "1D", True, 2)393 end_function(fs, "texture1DProjGradARB")394 start_function("texture2DProjGradARB")395 generate_fiu_sigs("txd", "2D", True)396 generate_fiu_sigs("txd", "2D", True, 1)397 end_function(fs, "texture2DProjGradARB")398 start_function("texture3DProjGradARB")399 generate_fiu_sigs("txd", "3D", True)400 end_function(fs, "texture3DProjGradARB")401 start_function("shadow1DGradARB")402 generate_sigs("", "txd", "1DShadow", False, 1)403 end_function(fs, "shadow1DGradARB")404 start_function("shadow1DProjGradARB")405 generate_sigs("", "txd", "1DShadow", True, 1)406 end_function(fs, "shadow1DProjGradARB")407 start_function("shadow2DGradARB")408 generate_sigs("", "txd", "2DShadow", False)409 end_function(fs, "shadow2DGradARB")410 start_function("shadow2DProjGradARB")411 generate_sigs("", "txd", "2DShadow", True)412 end_function(fs, "shadow2DProjGradARB")413 start_function("texture2DRectGradARB")414 generate_sigs("", "txd", "2DRect")415 end_function(fs, "texture2DRectGradARB")416 start_function("texture2DRectProjGradARB")417 generate_sigs("", "txd", "2DRect", True)418 generate_sigs("", "txd", "2DRect", True, 1)419 end_function(fs, "texture2DRectProjGradARB")420 start_function("shadow2DRectGradARB")421 generate_sigs("", "txd", "2DRectShadow", False)422 end_function(fs, "shadow2DRectGradARB")423 start_function("shadow2DRectProjGradARB")424 generate_sigs("", "txd", "2DRectShadow", True)425 end_function(fs, "shadow2DRectProjGradARB")426 # Deprecated (110/120 style) functions with silly names:427 start_function("texture1D")428 generate_sigs("", "tex", "1D")429 generate_sigs("", "txb", "1D")430 end_function(fs, "texture1D")431 start_function("texture1DLod")432 generate_sigs("", "txl", "1D")433 end_function(fs, "texture1DLod")434 start_function("texture1DProj")435 generate_sigs("", "tex", "1D", Proj)436 generate_sigs("", "tex", "1D", Proj, 2)437 generate_sigs("", "txb", "1D", Proj)438 generate_sigs("", "txb", "1D", Proj, 2)439 end_function(fs, "texture1DProj")440 start_function("texture1DProjLod")441 generate_sigs("", "txl", "1D", Proj)442 generate_sigs("", "txl", "1D", Proj, 2)443 end_function(fs, "texture1DProjLod")444 start_function("texture2D")445 generate_sigs("", "tex", "2D")446 generate_sigs("", "txb", "2D")447 # OES_EGL_image_external448 generate_sigs("", "tex", "ExternalOES")449 end_function(fs, "texture2D")450 start_function("texture2DLod")451 generate_sigs("", "txl", "2D")452 end_function(fs, "texture2DLod")453 start_function("texture2DProj")454 generate_sigs("", "tex", "2D", Proj)455 generate_sigs("", "tex", "2D", Proj, 1)456 generate_sigs("", "txb", "2D", Proj)457 generate_sigs("", "txb", "2D", Proj, 1)458 # OES_EGL_image_external459 generate_sigs("", "tex", "ExternalOES", Proj)460 generate_sigs("", "tex", "ExternalOES", Proj, 1)461 end_function(fs, "texture2DProj")462 start_function("texture2DProjLod")463 generate_sigs("", "txl", "2D", Proj)464 generate_sigs("", "txl", "2D", Proj, 1)465 end_function(fs, "texture2DProjLod")466 start_function("texture3D")467 generate_sigs("", "tex", "3D")468 generate_sigs("", "txb", "3D")469 end_function(fs, "texture3D")470 start_function("texture3DLod")471 generate_sigs("", "txl", "3D")472 end_function(fs, "texture3DLod")473 start_function("texture3DProj")474 generate_sigs("", "tex", "3D", Proj)475 generate_sigs("", "txb", "3D", Proj)476 end_function(fs, "texture3DProj")477 start_function("texture3DProjLod")478 generate_sigs("", "txl", "3D", Proj)479 end_function(fs, "texture3DProjLod")480 start_function("textureCube")481 generate_sigs("", "tex", "Cube")482 generate_sigs("", "txb", "Cube")483 end_function(fs, "textureCube")484 start_function("textureCubeLod")485 generate_sigs("", "txl", "Cube")486 end_function(fs, "textureCubeLod")487 start_function("shadow1D")488 generate_sigs("", "tex", "1DShadow", False, 1)489 generate_sigs("", "txb", "1DShadow", False, 1)490 end_function(fs, "shadow1D")491 start_function("shadow1DLod")492 generate_sigs("", "txl", "1DShadow", False, 1)493 end_function(fs, "shadow1DLod")494 start_function("shadow1DProj")495 generate_sigs("", "tex", "1DShadow", Proj, 1)496 generate_sigs("", "txb", "1DShadow", Proj, 1)497 end_function(fs, "shadow1DProj")498 start_function("shadow1DProjLod")499 generate_sigs("", "txl", "1DShadow", Proj, 1)500 end_function(fs, "shadow1DProjLod")501 start_function("shadow2D")502 generate_sigs("", "tex", "2DShadow")503 generate_sigs("", "txb", "2DShadow")504 end_function(fs, "shadow2D")505 start_function("shadow2DLod")506 generate_sigs("", "txl", "2DShadow")507 end_function(fs, "shadow2DLod")508 start_function("shadow2DProj")509 generate_sigs("", "tex", "2DShadow", Proj)510 generate_sigs("", "txb", "2DShadow", Proj)511 end_function(fs, "shadow2DProj")512 start_function("shadow2DProjLod")513 generate_sigs("", "txl", "2DShadow", Proj)514 end_function(fs, "shadow2DProjLod")515 sys.stdout = sys.__stdout__516 return fs517# If you actually run this script, it'll print out all the functions.518if __name__ == "__main__":519 fs = {}520 generate_texture_functions(fs);521 for k, v in fs.iteritems():...

Full Screen

Full Screen

population_test.py

Source:population_test.py Github

copy

Full Screen

1"""2Unit tests for the sbac_data_generation.generators.population module.3@author: nestep4@date: March 20, 20145"""6import data_generation.config.cfg as sbac_config7import sbac_data_generation.generators.hierarchy as hier_gen8import sbac_data_generation.generators.population as pop_gen9from data_generation.util.id_gen import IDGen10from nose.tools import assert_is_instance, assert_regexp_matches11from sbac_data_generation.model.student import SBACStudent12from sbac_data_generation.model.teachingstaff import SBACTeachingStaff13ID_GEN = IDGen()14GUID_REGEX = '[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}'15SR_GUID_REGEX = '[a-f0-9]{30}'16EXT_GUID_REGEX = GUID_REGEX + 'ext'17def test_generate_staff():18 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)19 district = hier_gen.generate_district('Big Average', state, ID_GEN)20 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)21 staff = pop_gen.generate_teaching_staff_member(school, ID_GEN)22 # Tests23 assert_is_instance(staff, SBACTeachingStaff)24 assert_regexp_matches(staff.guid_sr, SR_GUID_REGEX)25def test_generate_student():26 # Create objects27 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)28 district = hier_gen.generate_district('Big Average', state, ID_GEN)29 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)30 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)31 # Tests32 assert_is_instance(student, SBACStudent)33 assert_regexp_matches(student.guid_sr, SR_GUID_REGEX)34 assert_regexp_matches(student.external_ssid, EXT_GUID_REGEX)35 assert_regexp_matches(student.external_ssid_sr, SR_GUID_REGEX)36 assert student.school_entry_date.year == 200337 assert student.school_entry_date.month in [8, 9]38def test_advance_student_advanced():39 # Create objects40 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)41 district = hier_gen.generate_district('Big Average', state, ID_GEN)42 midl_school = hier_gen.generate_school('Middle School', district, ID_GEN, interim_asmt_rate=1)43 student = pop_gen.generate_student(midl_school, 6, ID_GEN, state, 2015)44 schools_by_grade = {grade: [midl_school] for grade in midl_school.grades}45 # Test46 assert pop_gen.advance_student(student, schools_by_grade, hold_back_rate=0)47def test_advance_student_held_back():48 # Create objects49 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)50 district = hier_gen.generate_district('Big Average', state, ID_GEN)51 midl_school = hier_gen.generate_school('Middle School', district, ID_GEN, interim_asmt_rate=1)52 student = pop_gen.generate_student(midl_school, 6, ID_GEN, state, 2015)53 schools_by_grade = {grade: [midl_school] for grade in midl_school.grades}54 # Test55 assert pop_gen.advance_student(student, schools_by_grade, hold_back_rate=1, drop_out_rate=0)56def test_advance_student_drop_out():57 # Create objects58 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)59 district = hier_gen.generate_district('Big Average', state, ID_GEN)60 high_school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)61 student = pop_gen.generate_student(high_school, 11, ID_GEN, state, 2015)62 schools_by_grade = {grade: [high_school] for grade in high_school.grades}63 # Test64 assert not pop_gen.advance_student(student, schools_by_grade, hold_back_rate=1, drop_out_rate=1)65def test_repopulate_school_grade_empty():66 # Create objects67 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)68 district = hier_gen.generate_district('Big Average', state, ID_GEN)69 elem_school = hier_gen.generate_school('Elementary School', district, ID_GEN)70 elem_school.config['students']['min'], elem_school.config['students']['max'] = 100, 10071 elem_school.config['students']['avg'] = 10072 students = []73 pop_gen.repopulate_school_grade(elem_school, 3, students, ID_GEN, state, 2015, additional_student_choice=[0])74 # Test75 assert len(students) == 10076def test_repopulate_school_grade_empty_with_additional():77 # Create objects78 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)79 district = hier_gen.generate_district('Big Average', state, ID_GEN)80 elem_school = hier_gen.generate_school('Elementary School', district, ID_GEN)81 elem_school.config['students']['min'], elem_school.config['students']['max'] = 100, 10082 elem_school.config['students']['avg'] = 10083 students = []84 pop_gen.repopulate_school_grade(elem_school, 3, students, ID_GEN, state, 2015, additional_student_choice=[3])85 # Test86 assert len(students) == 10387def test_repopulate_school_grade_full_no_additional():88 # Create objects89 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)90 district = hier_gen.generate_district('Big Average', state, ID_GEN)91 elem_school = hier_gen.generate_school('Elementary School', district, ID_GEN)92 elem_school.config['students']['min'], elem_school.config['students']['max'] = 100, 10093 elem_school.config['students']['avg'] = 10094 students = []95 for _ in range(100):96 students.append(pop_gen.generate_student(elem_school, 4, ID_GEN, state, 2015))97 pop_gen.repopulate_school_grade(elem_school, 4, students, ID_GEN, state, 2015, additional_student_choice=[0])98 # Test99 assert len(students) == 100100def test_repopulate_school_grade_full_additional():101 # Create objects102 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)103 district = hier_gen.generate_district('Big Average', state, ID_GEN)104 elem_school = hier_gen.generate_school('Elementary School', district, ID_GEN)105 elem_school.config['students']['min'], elem_school.config['students']['max'] = 100, 100106 elem_school.config['students']['avg'] = 100107 students = []108 for _ in range(100):109 students.append(pop_gen.generate_student(elem_school, 4, ID_GEN, state, 2015))110 pop_gen.repopulate_school_grade(elem_school, 4, students, ID_GEN, state, 2015, additional_student_choice=[2])111 # Test112 assert len(students) == 102113def test_repopulate_school_grade_almost_full_additional():114 # Create objects115 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)116 district = hier_gen.generate_district('Big Average', state, ID_GEN)117 elem_school = hier_gen.generate_school('Elementary School', district, ID_GEN)118 elem_school.config['students']['min'], elem_school.config['students']['max'] = 100, 100119 elem_school.config['students']['avg'] = 100120 students = []121 for _ in range(99):122 students.append(pop_gen.generate_student(elem_school, 4, ID_GEN, state, 2015))123 pop_gen.repopulate_school_grade(elem_school, 4, students, ID_GEN, state, 2015, additional_student_choice=[2])124 # Test125 assert len(students) == 102126def test_generate_derived_demographic_no_ethnicities():127 # Create objects128 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)129 district = hier_gen.generate_district('Big Average', state, ID_GEN)130 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)131 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)132 student.eth_amer_ind = False133 student.eth_asian = False134 student.eth_black = False135 student.eth_hispanic = False136 student.eth_multi = False137 student.eth_none = False138 student.eth_pacific = False139 student.eth_white = False140 # Test141 assert pop_gen._generate_derived_demographic(student) == -1142def test_generate_derived_demographic_amer_ind():143 # Create objects144 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)145 district = hier_gen.generate_district('Big Average', state, ID_GEN)146 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)147 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)148 student.eth_amer_ind = True149 student.eth_asian = False150 student.eth_black = False151 student.eth_hispanic = False152 student.eth_multi = False153 student.eth_none = False154 student.eth_pacific = False155 student.eth_white = False156 # Test157 assert pop_gen._generate_derived_demographic(student) == 4158def test_generate_derived_demographic_asian():159 # Create objects160 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)161 district = hier_gen.generate_district('Big Average', state, ID_GEN)162 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)163 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)164 student.eth_amer_ind = False165 student.eth_asian = True166 student.eth_black = False167 student.eth_hispanic = False168 student.eth_multi = False169 student.eth_none = False170 student.eth_pacific = False171 student.eth_white = False172 # Test173 assert pop_gen._generate_derived_demographic(student) == 2174def test_generate_derived_demographic_black():175 # Create objects176 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)177 district = hier_gen.generate_district('Big Average', state, ID_GEN)178 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)179 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)180 student.eth_amer_ind = False181 student.eth_asian = False182 student.eth_black = True183 student.eth_hispanic = False184 student.eth_multi = False185 student.eth_none = False186 student.eth_pacific = False187 student.eth_white = False188 # Test189 assert pop_gen._generate_derived_demographic(student) == 1190def test_generate_derived_demographic_hispanic():191 # Create objects192 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)193 district = hier_gen.generate_district('Big Average', state, ID_GEN)194 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)195 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)196 student.eth_amer_ind = False197 student.eth_asian = False198 student.eth_black = False199 student.eth_hispanic = True200 student.eth_multi = False201 student.eth_none = False202 student.eth_pacific = False203 student.eth_white = False204 # Test205 assert pop_gen._generate_derived_demographic(student) == 3206def test_generate_derived_demographic_multi():207 # Create objects208 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)209 district = hier_gen.generate_district('Big Average', state, ID_GEN)210 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)211 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)212 student.eth_amer_ind = False213 student.eth_asian = False214 student.eth_black = True215 student.eth_hispanic = False216 student.eth_multi = True217 student.eth_none = False218 student.eth_pacific = True219 student.eth_white = False220 # Test221 assert pop_gen._generate_derived_demographic(student) == 7222def test_generate_derived_demographic_multi_hispanic():223 # Create objects224 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)225 district = hier_gen.generate_district('Big Average', state, ID_GEN)226 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)227 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)228 student.eth_amer_ind = False229 student.eth_asian = False230 student.eth_black = False231 student.eth_hispanic = True232 student.eth_multi = True233 student.eth_none = False234 student.eth_pacific = True235 student.eth_white = False236 # Test237 assert pop_gen._generate_derived_demographic(student) == 3238def test_generate_derived_demographic_none():239 # Create objects240 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)241 district = hier_gen.generate_district('Big Average', state, ID_GEN)242 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)243 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)244 student.eth_amer_ind = False245 student.eth_asian = False246 student.eth_black = False247 student.eth_hispanic = False248 student.eth_multi = False249 student.eth_none = True250 student.eth_pacific = False251 student.eth_white = False252 # Test253 assert pop_gen._generate_derived_demographic(student) == 0254def test_generate_derived_demographic_pacific():255 # Create objects256 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)257 district = hier_gen.generate_district('Big Average', state, ID_GEN)258 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)259 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)260 student.eth_amer_ind = False261 student.eth_asian = False262 student.eth_black = False263 student.eth_hispanic = False264 student.eth_multi = False265 student.eth_none = False266 student.eth_pacific = True267 student.eth_white = False268 # Test269 assert pop_gen._generate_derived_demographic(student) == 5270def test_generate_derived_demographic_white():271 # Create objects272 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)273 district = hier_gen.generate_district('Big Average', state, ID_GEN)274 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)275 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)276 student.eth_amer_ind = False277 student.eth_asian = False278 student.eth_black = False279 student.eth_hispanic = False280 student.eth_multi = False281 student.eth_none = False282 student.eth_pacific = False283 student.eth_white = True284 # Test285 assert pop_gen._generate_derived_demographic(student) == 6286def test_set_lang_items_not_lep():287 # Create objects288 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)289 district = hier_gen.generate_district('Big Average', state, ID_GEN)290 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)291 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)292 student.prg_lep = False293 student.lang_code = None294 student.lang_prof_level = None295 student.lang_title_3_prg = None296 student.prg_lep_entry_date = None297 student.prg_lep_exit_date = None298 pop_gen._set_lang_items(student)299 # Tests300 assert student.lang_code is None301 assert student.lang_prof_level is None302 assert student.lang_title_3_prg is None303 assert student.prg_lep_entry_date is None304 assert student.prg_lep_exit_date is None305def test_set_lang_items_lep():306 # Create objects307 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)308 district = hier_gen.generate_district('Big Average', state, ID_GEN)309 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)310 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)311 student.prg_lep = True312 student.lang_code = None313 student.lang_prof_level = None314 student.lang_title_3_prg = None315 student.prg_lep_entry_date = None316 student.prg_lep_exit_date = None317 pop_gen._set_lang_items(student, lep_proficiency_levels_exit=[])318 # Tests319 assert student.lang_code in sbac_config.LEP_LANGUAGE_CODES320 assert student.lang_prof_level in sbac_config.LEP_PROFICIENCY_LEVELS321 assert student.lang_title_3_prg in sbac_config.LEP_TITLE_3_PROGRAMS322def test_set_lang_items_lep_no_entry_date():323 # Create objects324 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)325 district = hier_gen.generate_district('Big Average', state, ID_GEN)326 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)327 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)328 student.prg_lep = True329 student.lang_code = None330 student.lang_prof_level = None331 student.lang_title_3_prg = None332 student.prg_lep_entry_date = None333 student.prg_lep_exit_date = None334 pop_gen._set_lang_items(student, lep_has_entry_date_rate=0)335 # Tests336 assert student.prg_lep_entry_date is None337def test_set_lang_items_lep_entry_date_not_exited():338 # Create objects339 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)340 district = hier_gen.generate_district('Big Average', state, ID_GEN)341 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)342 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)343 student.prg_lep = True344 student.lang_code = None345 student.lang_prof_level = None346 student.lang_title_3_prg = None347 student.prg_lep_entry_date = None348 student.prg_lep_exit_date = None349 pop_gen._set_lang_items(student, lep_has_entry_date_rate=1, lep_proficiency_levels_exit=[])350 # Tests351 assert student.lang_title_3_prg in sbac_config.LEP_TITLE_3_PROGRAMS352 assert student.prg_lep_entry_date is not None353 assert student.prg_lep_exit_date is None354def test_set_lang_items_lep_entry_date_exited():355 # Create objects356 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)357 district = hier_gen.generate_district('Big Average', state, ID_GEN)358 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)359 student = pop_gen.generate_student(school, 11, ID_GEN, state, 2015)360 student.prg_lep = True361 student.lang_code = None362 student.lang_prof_level = None363 student.lang_title_3_prg = None364 student.prg_lep_entry_date = None365 student.prg_lep_exit_date = None366 pop_gen._set_lang_items(student, lep_has_entry_date_rate=1, lep_proficiency_levels=['good'],367 lep_proficiency_levels_exit=['good'])368 # Tests369 assert student.lang_title_3_prg is None370 assert student.prg_lep_entry_date is not None...

Full Screen

Full Screen

hierarchy_test.py

Source:hierarchy_test.py Github

copy

Full Screen

1"""2Unit tests for the sbac_data_generation.generators.hierarchy module.3@author: nestep4@date: March 20, 20145"""6import datetime7import sbac_data_generation.generators.hierarchy as hier_gen8from data_generation.util.id_gen import IDGen9from nose.tools import assert_is_instance, assert_raises, assert_regexp_matches10from sbac_data_generation.model.district import SBACDistrict11from sbac_data_generation.model.group import SBACgroup12from sbac_data_generation.model.school import SBACSchool13from sbac_data_generation.model.state import SBACState14ID_GEN = IDGen()15GUID_REGEX = '[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}'16SR_GUID_REGEX = '[a-f0-9]{30}'17def test_generate_state():18 # Create object19 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)20 # Tests21 assert_is_instance(state, SBACState)22 assert state.name == 'Example State'23 assert state.code == 'ES'24 assert_regexp_matches(state.guid_sr, SR_GUID_REGEX)25def test_generate_state_invalid_type():26 assert_raises(LookupError, hier_gen.generate_state, 'unknown', 'Example State', 'ES', ID_GEN)27def test_generate_district():28 # Create objects29 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)30 district = hier_gen.generate_district('Big Average', state, ID_GEN)31 # Tests32 assert_is_instance(district, SBACDistrict)33 assert district.state == state34 assert_regexp_matches(district.guid_sr, SR_GUID_REGEX)35def test_generate_district_invalid_type():36 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)37 assert_raises(LookupError, hier_gen.generate_district, 'unknown', state, ID_GEN)38def test_generate_school():39 # Create objects40 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)41 district = hier_gen.generate_district('Big Average', state, ID_GEN)42 school = hier_gen.generate_school('High School', district, ID_GEN)43 # Tests44 assert_is_instance(school, SBACSchool)45 assert school.district == district46 assert_regexp_matches(school.guid_sr, SR_GUID_REGEX)47def test_generate_school_invalid_type():48 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)49 district = hier_gen.generate_district('Big Average', state, ID_GEN)50 assert_raises(LookupError, hier_gen.generate_school, 'unknown', district, ID_GEN)51def test_generate_group():52 # Create objects53 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)54 district = hier_gen.generate_district('Big Average', state, ID_GEN)55 school = hier_gen.generate_school('High School', district, ID_GEN)56 group = hier_gen.generate_group('section_based', school, ID_GEN)57 # Tests58 assert_is_instance(group, SBACgroup)59 assert group.school == school60 assert_regexp_matches(group.guid_sr, SR_GUID_REGEX)61 assert group.type == 'section_based'62def test_generate_group_invalid_type():63 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)64 district = hier_gen.generate_district('Big Average', state, ID_GEN)65 school = hier_gen.generate_school('High School', district, ID_GEN)66 assert_raises(LookupError, hier_gen.generate_group, 'unknown', school, ID_GEN)67def test_generate_school_no_interims():68 # Create objects69 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)70 district = hier_gen.generate_district('Big Average', state, ID_GEN)71 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=0)72 # Test73 assert not school.takes_interim_asmts74def test_generate_school_interims():75 # Create objects76 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)77 district = hier_gen.generate_district('Big Average', state, ID_GEN)78 school = hier_gen.generate_school('High School', district, ID_GEN, interim_asmt_rate=1)79 # Test80 assert school.takes_interim_asmts81def test_generate_registration_system():82 rs = hier_gen.generate_registration_system(2015, '2014-02-15', ID_GEN)83 assert_regexp_matches(rs.guid, GUID_REGEX)84 assert_regexp_matches(rs.sys_guid, GUID_REGEX)85 assert rs.academic_year == 201586 assert rs.extract_date == '2014-02-15'87 assert rs.callback_url == 'SateTestReg.gov/StuReg/CallBack'88def test_generate_institution_hierarchy():89 # Create objects90 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)91 district = hier_gen.generate_district('Big Average', state, ID_GEN)92 school = hier_gen.generate_school('High School', district, ID_GEN)93 ih = hier_gen.generate_institution_hierarchy(state, district, school, ID_GEN)94 # Tests95 assert_is_instance(ih.rec_id, int)96 assert_regexp_matches(ih.guid, GUID_REGEX)97 assert ih.state == state98 assert ih.district == district99 assert ih.school == school100 assert ih.from_date == datetime.date(2012, 9, 1)101 assert ih.to_date == datetime.date(9999, 12, 31)102def test_sort_schools_by_grade():103 # Create objects104 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)105 district = hier_gen.generate_district('Big Average', state, ID_GEN)106 elem_school_1 = hier_gen.generate_school('Elementary School', district, ID_GEN)107 elem_school_2 = hier_gen.generate_school('Elementary School', district, ID_GEN)108 elem_school_3 = hier_gen.generate_school('Elementary School', district, ID_GEN)109 midl_school_1 = hier_gen.generate_school('Middle School', district, ID_GEN)110 midl_school_2 = hier_gen.generate_school('Middle School', district, ID_GEN)111 high_school = hier_gen.generate_school('High School', district, ID_GEN)112 schools_by_grade = hier_gen.sort_schools_by_grade([elem_school_1, elem_school_2, elem_school_3, midl_school_1,113 midl_school_2, high_school])114 # Tests115 assert len(schools_by_grade.keys()) == 7116 assert len(schools_by_grade[3]) == 3117 assert len(schools_by_grade[4]) == 3118 assert len(schools_by_grade[5]) == 3119 assert len(schools_by_grade[6]) == 2120 assert len(schools_by_grade[7]) == 2121 assert len(schools_by_grade[8]) == 2122 assert len(schools_by_grade[11]) == 1123def test_set_up_schools_with_grades():124 # Create objects125 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)126 district = hier_gen.generate_district('Big Average', state, ID_GEN)127 elem_school_1 = hier_gen.generate_school('Elementary School', district, ID_GEN)128 elem_school_2 = hier_gen.generate_school('Elementary School', district, ID_GEN)129 elem_school_3 = hier_gen.generate_school('Elementary School', district, ID_GEN)130 midl_school_1 = hier_gen.generate_school('Middle School', district, ID_GEN)131 midl_school_2 = hier_gen.generate_school('Middle School', district, ID_GEN)132 high_school = hier_gen.generate_school('High School', district, ID_GEN)133 schools_with_grades = hier_gen.set_up_schools_with_grades([elem_school_1, elem_school_2, elem_school_3,134 midl_school_1, midl_school_2, high_school],135 {3, 4, 5, 6, 7, 8, 11})136 # Tests137 assert len(schools_with_grades) == 6138 assert len(schools_with_grades[elem_school_1]) == 3139 assert len(schools_with_grades[elem_school_2]) == 3140 assert len(schools_with_grades[elem_school_3]) == 3141 assert len(schools_with_grades[midl_school_1]) == 3142 assert len(schools_with_grades[midl_school_2]) == 3143 assert len(schools_with_grades[high_school]) == 1144def test_set_up_schools_with_groupings():145 # Create objects146 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)147 district = hier_gen.generate_district('Big Average', state, ID_GEN)148 elem_school_1 = hier_gen.generate_school('Elementary School', district, ID_GEN)149 elem_school_2 = hier_gen.generate_school('Elementary School', district, ID_GEN)150 midl_school_1 = hier_gen.generate_school('Middle School', district, ID_GEN)151 midl_school_2 = hier_gen.generate_school('Middle School', district, ID_GEN)152 high_school = hier_gen.generate_school('High School', district, ID_GEN)153 schools_with_groupings = hier_gen.set_up_schools_with_groupings([elem_school_1, elem_school_2,154 midl_school_1, midl_school_2, high_school],155 {3, 4, 5, 6, 7, 8, 11})156 # Tests157 assert len(schools_with_groupings) == 5158 assert len(schools_with_groupings[elem_school_1]) == 3159 assert len(schools_with_groupings[elem_school_2]) == 3160 assert len(schools_with_groupings[midl_school_1]) == 3161 assert len(schools_with_groupings[midl_school_2]) == 3162 assert len(schools_with_groupings[high_school]) == 1163def test_populate_schools_with_groupings():164 # Create objects165 state = hier_gen.generate_state('devel', 'Example State', 'ES', ID_GEN)166 district = hier_gen.generate_district('Big Average', state, ID_GEN)167 elem_school_1 = hier_gen.generate_school('Elementary School', district, ID_GEN)168 elem_school_2 = hier_gen.generate_school('Elementary School', district, ID_GEN)169 midl_school_1 = hier_gen.generate_school('Middle School', district, ID_GEN)170 high_school = hier_gen.generate_school('High School', district, ID_GEN)171 schools_with_groupings = hier_gen.set_up_schools_with_groupings([elem_school_1, elem_school_2,172 midl_school_1, high_school],173 {3, 4, 5, 6, 7, 8, 11})174 pop_school_with_groupings = hier_gen.populate_schools_with_groupings(schools_with_groupings, ID_GEN)175 # Tests176 assert len(schools_with_groupings) == 4177 assert len(schools_with_groupings[elem_school_1]) == 3178 assert len(schools_with_groupings[elem_school_2]) == 3179 assert len(schools_with_groupings[midl_school_1]) == 3...

Full Screen

Full Screen

generate.py

Source:generate.py Github

copy

Full Screen

1from ctypes import c_void_p, byref2from ..lib import _lib3from ..key import Key4class Generate:5 def __init__(self, obj):6 self._obj = obj7 self._bits = None8 self._hashalg = None9 self._qbits = None10 self._curve = None11 self._password = None12 self._cipher = None13 self._s2k_hashalg = None14 self._protection_mode = None15 self._s2k_iterations = None16 self._usage = None17 self._uid = None18 self._lifetime = None19 self._preferences = None20 def __del__(self):21 _lib.rnp_op_generate_destroy(self._obj)22 def obj(self):23 return self._obj24 @staticmethod25 def start(rnp, typ):26 pop = c_void_p()27 _lib.rnp_op_generate_create(byref(pop), rnp.obj(), typ.encode("ascii"))28 if pop.value:29 return Generate(pop)30 @staticmethod31 def start_subkey(rnp, primary, typ):32 pop = c_void_p()33 _lib.rnp_op_generate_subkey_create(34 byref(pop), rnp.obj(), primary.obj(), typ.encode("ascii")35 )36 if pop.value:37 return Generate(pop)38 @property39 def bits(self):40 return self._bits41 @bits.setter42 def bits(self, value):43 _lib.rnp_op_generate_set_bits(self.obj(), value)44 self._bits = value45 @property46 def hashalg(self):47 return self._hashalg48 @hashalg.setter49 def hashalg(self, value):50 _lib.rnp_op_generate_set_hash(self.obj(), value.encode("ascii"))51 self._hashalg = value52 @property53 def qbits(self):54 return self._qbits55 @qbits.setter56 def qbits(self, value):57 _lib.rnp_op_generate_set_dsa_qbits(self.obj(), value)58 self._qbits = value59 @property60 def curve(self):61 return self._curve62 @curve.setter63 def curve(self, value):64 _lib.rnp_op_generate_set_curve(self.obj(), value.encode("ascii"))65 self._curve = value66 @property67 def password(self):68 return self._password69 @password.setter70 def password(self, value):71 _lib.rnp_op_generate_set_protection_password(self.obj(), value.encode("utf-8"))72 self._password = value73 @property74 def cipher(self):75 return self._cipher76 @cipher.setter77 def cipher(self, value):78 _lib.rnp_op_generate_set_protection_cipher(self.obj(), value.encode("ascii"))79 self._cipher = value80 @property81 def s2k_hashalg(self):82 return self._s2k_hashalg83 @s2k_hashalg.setter84 def s2k_hashalg(self, value):85 _lib.rnp_op_generate_set_protection_hash(self.obj(), value.encode("ascii"))86 self._s2k_hashalg = value87 @property88 def protection_mode(self):89 return self._protection_mode90 @protection_mode.setter91 def protection_mode(self, value):92 _lib.rnp_op_generate_set_protection_mode(self.obj(), value.encode("ascii"))93 self._protection_mode = value94 @property95 def s2k_iterations(self):96 return self._s2k_iterations97 @s2k_iterations.setter98 def s2k_iterations(self, value):99 _lib.rnp_op_generate_set_protection_iterations(self.obj(), value)100 self._s2k_iterations = value101 @property102 def usage(self):103 return self._usage104 @usage.setter105 def usage(self, value):106 _lib.rnp_op_generate_clear_usage(self.obj())107 if not isinstance(value, list):108 value = [value]109 for usage in value:110 _lib.rnp_op_generate_add_usage(self.obj(), usage.encode("ascii"))111 self._usage = value112 @property113 def uid(self):114 return self._uid115 @uid.setter116 def uid(self, value):117 _lib.rnp_op_generate_set_userid(self.obj(), value.encode("utf-8"))118 self._uid = value119 @property120 def lifetime(self):121 return self._lifetime122 @lifetime.setter123 def lifetime(self, value):124 _lib.rnp_op_generate_set_expiration(self.obj(), value)125 self._lifetime = value126 @property127 def preferences(self):128 return self._preferences129 @preferences.setter130 def preferences(self, value):131 _lib.rnp_op_generate_clear_pref_hashes(self.obj())132 _lib.rnp_op_generate_clear_pref_compression(self.obj())133 _lib.rnp_op_generate_clear_pref_ciphers(self.obj())134 _lib.rnp_op_generate_set_pref_keyserver(self.obj(), None)135 for alg in value.get("hashes"):136 _lib.rnp_op_generate_add_pref_hash(self.obj(), alg.encode("ascii"))137 for alg in value.get("compression"):138 _lib.rnp_op_generate_add_pref_compression(self.obj(), alg.encode("ascii"))139 for alg in value.get("ciphers"):140 _lib.rnp_op_generate_add_pref_cipher(self.obj(), alg.encode("ascii"))141 if value.get("key_server"):142 _lib.rnp_op_generate_set_pref_keyserver(143 self.obj(), value.get("key_server").encode("utf-8")144 )145 def finish(self):146 _lib.rnp_op_generate_execute(self.obj())147 handle = c_void_p()148 _lib.rnp_op_generate_get_key(self.obj(), byref(handle))149 if handle:...

Full Screen

Full Screen

gyptest-link-generate-manifest.py

Source:gyptest-link-generate-manifest.py Github

copy

Full Screen

1#!/usr/bin/env python2# Copyright (c) 2012 Google Inc. All rights reserved.3# Use of this source code is governed by a BSD-style license that can be4# found in the LICENSE file.5"""6Make sure we generate a manifest file when linking binaries, including7handling AdditionalManifestFiles.8"""9import TestGyp10import sys11if sys.platform == 'win32':12 import pywintypes13 import win32api14 import winerror15 RT_MANIFEST = 2416 class LoadLibrary(object):17 """Context manager for loading and releasing binaries in Windows.18 Yields the handle of the binary loaded."""19 def __init__(self, path):20 self._path = path21 self._handle = None22 def __enter__(self):23 self._handle = win32api.LoadLibrary(self._path)24 return self._handle25 def __exit__(self, type, value, traceback):26 win32api.FreeLibrary(self._handle)27 def extract_manifest(path, resource_name):28 """Reads manifest from |path| and returns it as a string.29 Returns None is there is no such manifest."""30 with LoadLibrary(path) as handle:31 try:32 return win32api.LoadResource(handle, RT_MANIFEST, resource_name)33 except pywintypes.error as error:34 if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND:35 return None36 else:37 raise38 test = TestGyp.TestGyp(formats=['msvs', 'ninja'])39 CHDIR = 'linker-flags'40 test.run_gyp('generate-manifest.gyp', chdir=CHDIR)41 test.build('generate-manifest.gyp', test.ALL, chdir=CHDIR)42 # Make sure that generation of .generated.manifest does not cause a relink.43 test.run_gyp('generate-manifest.gyp', chdir=CHDIR)44 test.up_to_date('generate-manifest.gyp', test.ALL, chdir=CHDIR)45 def test_manifest(filename, generate_manifest, embedded_manifest,46 extra_manifest):47 exe_file = test.built_file_path(filename, chdir=CHDIR)48 if not generate_manifest:49 test.must_not_exist(exe_file + '.manifest')50 manifest = extract_manifest(exe_file, 1)51 test.fail_test(manifest)52 return53 if embedded_manifest:54 manifest = extract_manifest(exe_file, 1)55 test.fail_test(not manifest)56 else:57 test.must_exist(exe_file + '.manifest')58 manifest = test.read(exe_file + '.manifest')59 test.fail_test(not manifest)60 test.fail_test(extract_manifest(exe_file, 1))61 if generate_manifest:62 test.must_contain_any_line(manifest, 'requestedExecutionLevel')63 if extra_manifest:64 test.must_contain_any_line(manifest,65 '35138b9a-5d96-4fbd-8e2d-a2440225f93a')66 test.must_contain_any_line(manifest,67 'e2011457-1546-43c5-a5fe-008deee3d3f0')68 test_manifest('test_generate_manifest_true.exe',69 generate_manifest=True,70 embedded_manifest=False,71 extra_manifest=False)72 test_manifest('test_generate_manifest_false.exe',73 generate_manifest=False,74 embedded_manifest=False,75 extra_manifest=False)76 test_manifest('test_generate_manifest_default.exe',77 generate_manifest=True,78 embedded_manifest=False,79 extra_manifest=False)80 test_manifest('test_generate_manifest_true_as_embedded.exe',81 generate_manifest=True,82 embedded_manifest=True,83 extra_manifest=False)84 test_manifest('test_generate_manifest_false_as_embedded.exe',85 generate_manifest=False,86 embedded_manifest=True,87 extra_manifest=False)88 test_manifest('test_generate_manifest_default_as_embedded.exe',89 generate_manifest=True,90 embedded_manifest=True,91 extra_manifest=False)92 test_manifest('test_generate_manifest_true_with_extra_manifest.exe',93 generate_manifest=True,94 embedded_manifest=False,95 extra_manifest=True)96 test_manifest('test_generate_manifest_false_with_extra_manifest.exe',97 generate_manifest=False,98 embedded_manifest=False,99 extra_manifest=True)100 test_manifest('test_generate_manifest_true_with_extra_manifest_list.exe',101 generate_manifest=True,102 embedded_manifest=False,103 extra_manifest=True)104 test_manifest('test_generate_manifest_false_with_extra_manifest_list.exe',105 generate_manifest=False,106 embedded_manifest=False,107 extra_manifest=True)108 test_manifest('test_generate_manifest_default_embed_default.exe',109 generate_manifest=True,110 embedded_manifest=True,111 extra_manifest=False)...

Full Screen

Full Screen

configurations.py

Source:configurations.py Github

copy

Full Screen

1import os2from Transparency.common_code.common import *3def generate_basic_config(dataset, exp_name) :4 config = {5 'model' :{6 'encoder' : {7 'vocab_size' : dataset.vec.vocab_size,8 'embed_size' : dataset.vec.word_dim9 },10 'decoder' : {11 'attention' : {12 'type' : 'tanh'13 },14 'output_size' : dataset.output_size15 }16 },17 'training' : {18 'bsize' : dataset.bsize if hasattr(dataset, 'bsize') else 32,19 'weight_decay' : 1e-5,20 'pos_weight' : dataset.pos_weight if hasattr(dataset, 'pos_weight') else None,21 'basepath' : dataset.basepath if hasattr(dataset, 'basepath') else 'outputs',22 'exp_dirname' : os.path.join(dataset.name, exp_name)23 }24 }25 return config26def generate_lstm_config(dataset) :27 config = generate_basic_config(dataset, exp_name='lstm+tanh')28 hidden_size = dataset.hidden_size if hasattr(dataset, 'hidden_size') else 12829 config['model']['encoder'].update({'type': 'rnn', 'hidden_size' : hidden_size})30 return config31def generate_average_config(dataset) :32 config = generate_basic_config(dataset, exp_name='average+tanh')33 hidden_size = dataset.hidden_size if hasattr(dataset, 'hidden_size') else 12834 config['model']['encoder'].update({'projection' : True, 'hidden_size' : hidden_size, 'activation' : 'tanh', 'type' : 'average'})35 return config36def generate_cnn_config(dataset, filters=(1, 3, 5, 7)) :37 config = generate_basic_config(dataset, exp_name='cnn' + str(filters).replace(' ', '') + '+tanh')38 hidden_size = dataset.hidden_size if hasattr(dataset, 'hidden_size') else 12839 config['model']['encoder'].update({'kernel_sizes': filters, 'hidden_size' : hidden_size // len(filters), 'activation' : 'relu', 'type': 'cnn'})40 return config41def generate_vanilla_lstm_config(dataset) :42 config = generate_lstm_config(dataset)43 config['model']['decoder']['use_attention'] = False44 config['training']['exp_dirname'] = os.path.join(dataset.name, 'lstm')45 return config46def generate_logodds_config(dataset) :47 config = generate_lstm_config(dataset)48 model = get_latest_model(os.path.join('outputs', dataset.name, 'LR+TFIDF'))49 config['model']['decoder']['attention'] = {50 'type' : 'logodds',51 'logodds_file' : os.path.join(model, 'logodds.p')52 }53 config['training']['exp_dirname'] = os.path.join(dataset.name, 'lstm+logodds')54 return config55def generate_logodds_regularised_config(dataset) :56 config = generate_lstm_config(dataset)57 model = get_latest_model(os.path.join('outputs', dataset.name, 'LR+TFIDF'))58 config['model']['decoder']['regularizer_attention'] = {59 'type' : 'logodds',60 'logodds_file' : os.path.join(model, 'logodds.p')61 }62 config['training']['exp_dirname'] = os.path.join(dataset.name, 'lstm+logodds(Reg)')63 return config64def generate_vanilla_cnn_config(dataset) :65 config = generate_cnn_config(dataset)66 config['model']['decoder']['use_attention'] = False67 config['training']['exp_dirname'] = os.path.join(dataset.name, 'cnn')68 return config69def generate_single_cnn_config(dataset) :70 config = generate_cnn_config(dataset, filters=(3,))71 config['training']['exp_dirname'] = os.path.join(dataset.name, 'cnn(3)+tanh')72 return config73def make_attention_dot(func) :74 def new_func(dataset) :75 config = func(dataset)76 config['model']['decoder']['attention']['type'] = 'dot'77 config['training']['exp_dirname'] = config['training']['exp_dirname'].replace('tanh', 'dot')78 return config79 return new_func80configurations = {81 'vanilla_lstm' : generate_vanilla_lstm_config,82 'vanilla_cnn' : generate_vanilla_cnn_config,83 'lstm' : generate_lstm_config,84 'average' : generate_average_config,85 'cnn' : generate_cnn_config,86 'logodds_lstm' : generate_logodds_config,87 'logodds_lstm_reg' : generate_logodds_regularised_config,88 'single_cnn' : generate_single_cnn_config,89 'lstm_dot' : make_attention_dot(generate_lstm_config),90 'cnn_dot' : make_attention_dot(generate_cnn_config),91 'average_dot' : make_attention_dot(generate_average_config)92}93def wrap_config_for_qa(func) :94 def new_func(dataset) :95 config = func(dataset)96 config['model']['decoder']['attention']['type'] += '_qa'97 return config98 return new_func...

Full Screen

Full Screen

models.py

Source:models.py Github

copy

Full Screen

...59 def generate_validation_error_safe_eval(self):60 self.generate_safe_eval(self.generate_validation_error)61 def generate_safe_eval(self, f):62 globals_dict = { 'generate': f }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const { generate } = require('@storybook/root-config');3generate({4 outputDir: path.resolve(__dirname, '../.storybook'),5 configDir: path.resolve(__dirname, '../.storybook'),6});7const path = require('path');8module.exports = {9 presets: [path.resolve(__dirname, './presets.js')],10};11module.exports = ['@storybook/addon-docs/preset'];

Full Screen

Using AI Code Generation

copy

Full Screen

1import { generate } from 'storybook-root-decorator';2const decorator = generate();3export default {4};5import React from 'react';6import { storiesOf } from '@storybook/react';7import Button from './Button';8storiesOf('Button', module)9 .add('Default', () => <Button>Click me</Button>)10 .add('Disabled', () => <Button disabled>Click me</Button>);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { generateRootWrapper } from 'storybook-root-wrapper';2const rootWrapper = generateRootWrapper({ theme: { primary: '#ff0000' } });3export const decorators = [rootWrapper];4export const parameters = {5 actions: { argTypesRegex: '^on[A-Z].*' },6};7import { generateRootWrapper } from 'storybook-root-wrapper';8import Button from './Button';9const rootWrapper = generateRootWrapper({ theme: { primary: '#ff0000' } });10export default {11};12const Template = (args) => <Button {...args} />;13export const Primary = Template.bind({});14Primary.args = {15};16export const Secondary = Template.bind({});17Secondary.args = {18};19export const Large = Template.bind({});20Large.args = {21};22export const Small = Template.bind({});23Small.args = {24};25import { generateRootWrapper } from 'storybook-root-wrapper';26import Button from './Button';27export default {28 parameters: {29 rootWrapper: {30 theme: {31 },32 },33 },34};35const Template = (args) => <Button {...args} />;36export const Primary = Template.bind({});37Primary.args = {38};39export const Secondary = Template.bind({});40Secondary.args = {41};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { generate } from 'storybook-root-cause';2generate({3 storybookBuildOptions: {4 },5 storybookWebpackConfig: {6 module: {7 {8 test: /\.(js|jsx)$/,9 options: {10 {11 targets: {12 },13 },

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 storybook-root 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