<s> from comport . data . cleaners import Cleaners , RESIDENT_WEAPONS_LOOKUP , OFFICER_FORCE_TYPE_LOOKUP , RACE_LOOKUP , GENDER_LOOKUP , CAPITALIZE_LIST , CAPITALIZE_IGNORE_KEYS_LIST <EOL> from titlecase import titlecase <EOL> class TestCleaners : <EOL> def test_unknown_resident_weapon_returned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> weapon = "<STR_LIT>" <EOL> cleaned = cleaner . resident_weapon_used ( weapon ) <EOL> assert cleaned == weapon <EOL> def test_known_resident_weapons_cleaned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> for weapon in RESIDENT_WEAPONS_LOOKUP : <EOL> check_weapon = cleaner . resident_weapon_used ( weapon ) <EOL> assert check_weapon == RESIDENT_WEAPONS_LOOKUP [ weapon ] <EOL> def test_unknown_officer_force_type_returned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> force_type = "<STR_LIT>" <EOL> cleaned = cleaner . officer_force_type ( force_type ) <EOL> assert cleaned == force_type <EOL> def test_known_officer_force_types_cleaned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> for force_type in OFFICER_FORCE_TYPE_LOOKUP : <EOL> check_force_type = cleaner . officer_force_type ( force_type ) <EOL> assert check_force_type == OFFICER_FORCE_TYPE_LOOKUP [ force_type ] <EOL> def test_unknown_race_returned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> race = "<STR_LIT>" <EOL> cleaned = cleaner . race ( race ) <EOL> assert cleaned == race <EOL> def test_known_races_cleaned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> for race in RACE_LOOKUP : <EOL> check_race = cleaner . race ( race ) <EOL> assert check_race == RACE_LOOKUP [ race ] <EOL> def test_unknown_gender_returned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> gender = "<STR_LIT>" <EOL> cleaned = cleaner . sex ( gender ) <EOL> assert cleaned == gender <EOL> def test_known_genders_cleaned ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> for gender in GENDER_LOOKUP : <EOL> check_gender = cleaner . sex ( gender ) <EOL> assert check_gender == GENDER_LOOKUP [ gender ] <EOL> def test_capitalization ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> in_sentence = "<STR_LIT>" <EOL> titlecased_sentence = titlecase ( in_sentence ) <EOL> send = "<STR_LIT:U+0020>" . join ( i . lower ( ) + "<STR_LIT:U+0020>" + j . lower ( ) for i , j in zip ( in_sentence . split ( "<STR_LIT:U+0020>" ) , CAPITALIZE_LIST ) ) <EOL> check = "<STR_LIT:U+0020>" . join ( i + "<STR_LIT:U+0020>" + j for i , j in zip ( titlecased_sentence . split ( "<STR_LIT:U+0020>" ) , CAPITALIZE_LIST ) ) <EOL> result = cleaner . capitalize ( send ) <EOL> assert check == result <EOL> def test_captilization_handles_non_strings ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> send_int = <NUM_LIT> <EOL> send_float = <NUM_LIT> <EOL> send_list = [ "<STR_LIT:I>" , "<STR_LIT>" , "<STR_LIT:I>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> result_int = cleaner . capitalize ( send_int ) <EOL> result_float = cleaner . capitalize ( send_float ) <EOL> result_list = cleaner . capitalize ( send_list ) <EOL> assert send_int == result_int <EOL> assert send_float == result_float <EOL> assert send_list == result_list <EOL> def test_incident_capitalization ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> in_sentence = "<STR_LIT>" <EOL> titlecased_sentence = titlecase ( in_sentence ) <EOL> send = { } <EOL> send [ "<STR_LIT>" ] = in_sentence <EOL> send [ "<STR_LIT>" ] = in_sentence <EOL> for key in CAPITALIZE_IGNORE_KEYS_LIST : <EOL> send [ key ] = in_sentence <EOL> result = cleaner . capitalize_incident ( send ) <EOL> assert result [ "<STR_LIT>" ] == titlecased_sentence <EOL> assert result [ "<STR_LIT>" ] == titlecased_sentence <EOL> for key in CAPITALIZE_IGNORE_KEYS_LIST : <EOL> assert result [ key ] == in_sentence <EOL> def test_number_to_string ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> in_int = <NUM_LIT> <EOL> in_float = <NUM_LIT> <EOL> in_string = "<STR_LIT>" <EOL> in_list = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> in_none = None <EOL> assert cleaner . number_to_string ( in_int ) == str ( in_int ) <EOL> assert cleaner . number_to_string ( in_float ) == str ( in_float ) <EOL> assert cleaner . number_to_string ( in_string ) == in_string <EOL> assert cleaner . number_to_string ( in_list ) == in_list <EOL> assert cleaner . number_to_string ( in_none ) is None <EOL> def test_string_to_integer ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaner = Cleaners ( ) <EOL> in_string_success_int = '<STR_LIT>' <EOL> in_string_success_float = '<STR_LIT>' <EOL> in_int = <NUM_LIT> <EOL> in_float = <NUM_LIT> <EOL> in_string_fail = '<STR_LIT>' <EOL> in_list = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> in_none = None <EOL> assert cleaner . string_to_integer ( in_string_success_int ) == int ( in_string_success_int ) <EOL> assert cleaner . string_to_integer ( in_string_success_float ) == int ( float ( in_string_success_float ) ) <EOL> assert cleaner . string_to_integer ( in_int ) == in_int <EOL> assert cleaner . string_to_integer ( in_float ) == int ( in_float ) <EOL> assert cleaner . string_to_integer ( in_string_fail ) is None <EOL> assert cleaner . string_to_integer ( in_list ) is None <EOL> assert cleaner . string_to_integer ( in_none ) is None </s>
