#NEWLINE# def test_post_ois_data( self , testapp ) : #NEWLINE# #INDENT# ' New OIS data from the extractor is processed as expected.\n        ' #NEWLINE# department = Department . create ( name = 'Good Police Department' , short_name = 'GPD' , load_defaults = False ) #NEWLINE# ( extractor , envs ) = Extractor . from_department_and_password ( department = department , password = 'password' ) #NEWLINE# testapp . authorization = ( 'Basic' , ( extractor . username , 'password' ) ) #NEWLINE# test_client = JSONTestClient ( ) #NEWLINE# ois_count = 1 #NEWLINE# ois_data = test_client . get_prebaked_ois ( last = ois_count ) #NEWLINE# response = testapp . post_json ( '/data/OIS' , params = { #NEWLINE# #INDENT# 'month' : 0 , #NEWLINE# 'year' : 0 , #NEWLINE# 'data' : ois_data , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( response . status_code == 200 ) #NEWLINE# assert ( response . json_body [ 'updated' ] == 0 ) #NEWLINE# assert ( response . json_body [ 'added' ] == ois_count ) #NEWLINE# cleaner = Cleaners ( ) #NEWLINE# sent_ois = ois_data [ 0 ] #NEWLINE# check_ois = OfficerInvolvedShooting . query . filter_by ( opaque_id = sent_ois [ 'opaqueId' ] ) . first ( ) #NEWLINE# assert ( check_ois . occured_date . strftime ( '%Y-%m-%d %-H:%-M:%S' ) == sent_ois [ 'occuredDate' ] ) #NEWLINE# assert ( check_ois . division == cleaner . capitalize ( sent_ois [ 'division' ] ) ) #NEWLINE# assert ( check_ois . precinct == cleaner . capitalize ( sent_ois [ 'precinct' ] ) ) #NEWLINE# assert ( check_ois . shift == cleaner . capitalize ( sent_ois [ 'shift' ] ) ) #NEWLINE# assert ( check_ois . beat == cleaner . capitalize ( sent_ois [ 'beat' ] ) ) #NEWLINE# assert ( check_ois . disposition == sent_ois [ 'disposition' ] ) #NEWLINE# assert ( check_ois . resident_race == cleaner . race ( sent_ois [ 'residentRace' ] ) ) #NEWLINE# assert ( check_ois . resident_sex == cleaner . sex ( sent_ois [ 'residentSex' ] ) ) #NEWLINE# assert ( check_ois . resident_age == cleaner . number_to_string ( sent_ois [ 'residentAge' ] ) ) #NEWLINE# assert ( check_ois . resident_weapon_used == cleaner . resident_weapon_used ( sent_ois [ 'residentWeaponUsed' ] ) ) #NEWLINE# assert ( check_ois . resident_condition == sent_ois [ 'residentCondition' ] ) #NEWLINE# assert ( check_ois . officer_identifier == sent_ois [ 'officerIdentifier' ] ) #NEWLINE# assert ( check_ois . officer_weapon_used == sent_ois [ 'officerForceType' ] ) #NEWLINE# assert ( check_ois . officer_race == cleaner . race ( sent_ois [ 'officerRace' ] ) ) #NEWLINE# assert ( check_ois . officer_sex == cleaner . sex ( sent_ois [ 'officerSex' ] ) ) #NEWLINE# assert ( check_ois . officer_age == cleaner . number_to_string ( sent_ois [ 'officerAge' ] ) ) #NEWLINE# assert ( check_ois . officer_years_of_service == cleaner . string_to_integer ( sent_ois [ 'officerYearsOfService' ] ) ) #NEWLINE# assert ( check_ois . officer_condition == sent_ois [ 'officerCondition' ] )