def test_address_check_returns_empty_list_if_no_addresses_found(): df = pd.DataFrame({ "nonPrivateColumn1": ["a", "b", "c"], "nonPrivateColumn2": ["a", "b", "c"] }) actual_private_columns = pp.check_addresses(df) expected_private_columns = [] assert actual_private_columns == expected_private_columns
def test_does_not_identify_non_whitelisted_street_types_as_addresses(address): df = pd.DataFrame({ "privateColumn": ["a", address, "c"], "nonPrivateColumn": ["a", "b", "c"] }) actual_private_columns = pp.check_addresses(df) expected_private_columns = [] assert actual_private_columns == expected_private_columns
def test_can_identify_column_containing_simple_street_names(address): df = pd.DataFrame({ "privateColumn": ["a", address, "c"], "nonPrivateColumn": ["a", "b", "c"] }) actual_private_columns = pp.check_addresses(df) expected_private_columns = ["privateColumn"] assert actual_private_columns == expected_private_columns
def test_can_identify_column_containing_UK_postcode(postcode): df = pd.DataFrame({ "privateColumn": ["a", postcode, "c"], "nonPrivateColumn": ["a", "b", "c"] }) actual_private_columns = pp.check_addresses(df) expected_private_columns = ["privateColumn"] assert actual_private_columns == expected_private_columns
def test_does_not_identify_non_whitelisted_suffixes_as_emails(email): df = pd.DataFrame({ "privateColumn": ["a", email, "c"], "nonPrivateColumn": ["a", "b", "c"] }) actual_private_columns = pp.check_addresses(df) expected_private_columns = [] assert actual_private_columns == expected_private_columns
def test_check_addresses_can_handle_mixed_dtype_columns(): df = pd.DataFrame({ "privateColumn": [True, "AB1 1AB", "c"], "privateColumn2": [1, "b", "10 Downing Street"], "nonPrivateColumn": [0, True, "test"], }) actual_private_columns = pp.check_addresses(df) expected_private_columns = ["privateColumn", "privateColumn2"] assert actual_private_columns == expected_private_columns