def test_remove_ambiguous_addresses_by_uprn_withmatches(self): in_list = [ { "address": "1 Haringey Park, London", "postcode": "N89JG", "polling_station_id": "AA", "council": "X01000001", "slug": "1-haringey-park-london-n89jg-aa", "uprn": "1001", }, { "address": "2 Haringey Park, London", "postcode": "N89JG", "polling_station_id": "AB", "council": "X01000001", "slug": "2-haringey-park-london-n89jg-ab", "uprn": "1001", }, { "address": "3 Haringey Park, London", "postcode": "N89JG", "polling_station_id": "AB", "council": "X01000001", "slug": "3-haringey-park-london-n89jg-ab", "uprn": "1003", }, { "address": "4 Haringey Park, London", "postcode": "N89JH", "polling_station_id": "AC", "council": "X01000001", "slug": "4-haringey-park-london-n89jh-ac", "uprn": "1004", }, ] """ 1 Haringey Park, London and 2 Haringey Park, London both have the same UPRN (1001) but they map to different stations so we should remove all the N89JG addresses, leaving only 4 Haringey Park, London """ expected = [in_list[3]] address_list = AddressList(MockLogger()) for el in in_list: address_list.append(el) address_list.remove_ambiguous_addresses_by_uprn() self.assertEqual(expected, address_list.elements)
def test_remove_ambiguous_addresses_by_uprn_nomatches(self): in_list = [ { "address": "1 Haringey Park, London", "postcode": "N89JG", "polling_station_id": "AA", "council": "X01000001", "slug": "1-haringey-park-london-n89jg-aa", "uprn": "1001", }, { "address": "2 Haringey Park, London", "postcode": "N89JG", "polling_station_id": "AB", "council": "X01000001", "slug": "2-haringey-park-london-n89jg-ab", "uprn": "1002", }, { "address": "3 Haringey Park, London", "postcode": "N89JG", "polling_station_id": "AB", "council": "X01000001", "slug": "3-haringey-park-london-n89jg-ab", "uprn": "1003", }, ] # Everything has a unique UPRN # so we shouldn't remove anything expected = in_list address_list = AddressList(MockLogger()) for el in in_list: address_list.append(el) address_list.remove_ambiguous_addresses_by_uprn() self.assertEqual(expected, address_list.elements)