def test_check_sdn_fallback_other_fields(self): """ Verify that country, type and source need to match for checkSDNFallback to return True """ # wrong country # pylint: disable=line-too-long csv_string = """_id,source,entity_number,type,programs,name,title,addresses,federal_register_notice,start_date,end_date,standard_order,license_requirement,license_policy,call_sign,vessel_type,gross_tonnage,gross_registered_tonnage,vessel_flag,vessel_owner,remarks,source_list_url,alt_names,citizenships,dates_of_birth,nationalities,places_of_birth,source_information_url,ids 94734218,Specially Designated Nationals (SDN) - Treasury Department,96663868,Individual,material,Juan M. de la Cruz,Dr.,"17472 Christie Stream Apt. 976 North Kristinaport, HI 91033, SN",,,,,,,,,,,,,,https://www.juarez-collier.org/,Wendy Brock,DJ,1944-03-05,Faroe Islands,PK,http://richardson-richardson.org/,CI""" # pylint: enable=line-too-long metadata_entry = populate_sdn_fallback_data_and_metadata(csv_string) self.assertEqual(checkSDNFallback("Juan", "Kristinaport", 'AB'), 0) # wrong type # pylint: disable=line-too-long csv_string = """_id,source,entity_number,type,programs,name,title,addresses,federal_register_notice,start_date,end_date,standard_order,license_requirement,license_policy,call_sign,vessel_type,gross_tonnage,gross_registered_tonnage,vessel_flag,vessel_owner,remarks,source_list_url,alt_names,citizenships,dates_of_birth,nationalities,places_of_birth,source_information_url,ids 94734218,Specially Designated Nationals (SDN) - Treasury Department,96663868,foo,material,Juan M. de la Cruz,Dr.,"17472 Christie Stream Apt. 976 North Kristinaport, HI 91033, SN",,,,,,,,,,,,,,https://www.juarez-collier.org/,Wendy Brock,DJ,1944-03-05,Faroe Islands,PK,http://richardson-richardson.org/,CI""" # pylint: enable=line-too-long metadata_entry = populate_sdn_fallback_data_and_metadata(csv_string) self.assertEqual(checkSDNFallback("Juan", "Kristinaport", 'SN'), 0) # wrong source # pylint: disable=line-too-long csv_string = """_id,source,entity_number,type,programs,name,title,addresses,federal_register_notice,start_date,end_date,standard_order,license_requirement,license_policy,call_sign,vessel_type,gross_tonnage,gross_registered_tonnage,vessel_flag,vessel_owner,remarks,source_list_url,alt_names,citizenships,dates_of_birth,nationalities,places_of_birth,source_information_url,ids 94734218,bar,96663868,Individual,material,Juan M. de la Cruz,Dr.,"17472 Christie Stream Apt. 976 North Kristinaport, HI 91033, SN",,,,,,,,,,,,,,https://www.juarez-collier.org/,Wendy Brock,DJ,1944-03-05,Faroe Islands,PK,http://richardson-richardson.org/,CI""" # pylint: enable=line-too-long metadata_entry = populate_sdn_fallback_data_and_metadata(csv_string) self.assertEqual(checkSDNFallback("Juan", "Kristinaport", 'SN'), 0)
def test_sdn_fallback_multiple_hits(self): """ Verify SDNFallback can handle returning multiple hits if it finds a hit more than once. """ csv_string = """_id,source,entity_number,type,programs,name,title,addresses,federal_register_notice,start_date,end_date,standard_order,license_requirement,license_policy,call_sign,vessel_type,gross_tonnage,gross_registered_tonnage,vessel_flag,vessel_owner,remarks,source_list_url,alt_names,citizenships,dates_of_birth,nationalities,places_of_birth,source_information_url,ids 94734218,Specially Designated Nationals (SDN) - Treasury Department,96663868,Individual,material,Juan M. de la Cruz,Dr.,"17472 Christie Stream Apt. 976 North Kristinaport, HI 91033, SN",,,,,,,,,,,,,,https://www.cruz.org/,Wendy Brock,DJ,1944-03-05,Faroe Islands,PK,http://juan.org/,CI 94734219,Specially Designated Nationals (SDN) - Treasury Department,96663869,Individual,material,Juan Cruz,Dr.,"123 Main Street North Kristinaport, HI 91033, SN",,,,,,,,,,,,,,https://www.juarez-collier.org/,Wendy Brock,DJ,1944-03-05,Faroe Islands,PK,http://richardson-richardson.org/,CI 37539856,Specially Designated Nationals (SDN) - Treasury Department,55159852,Individual,hotel,Sarah Jones,Mrs.,"3699 Daniel Highway Port Andrewport, OR 39456, EE",,,,,,,,,,,,,,http://douglas.com/,Misty Johnson,CV,1998-02-15,Ukraine,BO,https://townsend.com/,TM""" populate_sdn_fallback_data_and_metadata(csv_string) sdn_fallback_hit_count = checkSDNFallback('Juan Cruz', 'North Kristinaport', 'SN') self.assertEqual(sdn_fallback_hit_count, 2)
def test_check_sdn_fallback_address(self, address, match): """ Verify that the following properties are true for addresses: 1. Order of words doesn’t matter 2. Number of times that a given word appears doesn’t matter 3. Punctuation between words or at the beginning/end of a given word doesn’t matter 4. If a subset of words match, it still counts as a match 5. Capitalization doesn’t matter """ # pylint: disable=line-too-long csv_string = """_id,source,entity_number,type,programs,name,title,addresses,federal_register_notice,start_date,end_date,standard_order,license_requirement,license_policy,call_sign,vessel_type,gross_tonnage,gross_registered_tonnage,vessel_flag,vessel_owner,remarks,source_list_url,alt_names,citizenships,dates_of_birth,nationalities,places_of_birth,source_information_url,ids 94734218,Specially Designated Nationals (SDN) - Treasury Department,96663868,Individual,material,Juan M. de la Cruz,Dr.,"17472 Christie Stream Apt. 976 North Kristinaport João 中国, HI 91033, SN",,,,,,,,,,,,,,https://www.juarez-collier.org/,Wendy Brock,DJ,1944-03-05,Faroe Islands,PK,http://richardson-richardson.org/,CI""" # pylint: enable=line-too-long metadata_entry = populate_sdn_fallback_data_and_metadata(csv_string) self.assertEqual(checkSDNFallback("Juan", address, 'SN'), match)
def test_SDNFallback_empty_data(self): """ when checkSDNFallback is called and data isn't populated, we throw the expected Exception """ with self.assertRaises(SDNFallbackDataEmptyError): checkSDNFallback('Juan', 'North Kristinaport', 'SN')