def setUp(self): self.df = pd.DataFrame({ "id": [1], "address": ["This isn't an address."] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df = self.geocoder.geocode_df()
def setUp(self): self.df = pd.DataFrame({ "id": [1], "address": ["1 City Hall Plz, Boston, 02108"] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df = self.geocoder.geocode_df()
def setUp(self): self.df = pd.DataFrame({ "id": [1, 2], "address": ["89 Orleans Street Boston MA, 02128", None] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df_with_Nulls = self.geocoder.geocode_df()
def setUp(self): self.df = pd.DataFrame({ "id": [1], "address": ["89 Orleans Street Boston MA, 02128"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode)
def setUp(self): SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"] self.df = pd.DataFrame({ "id": [1], "address": ["890 Commonwealth Avenue"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode) self.picked_candidate = self.geocoder._pick_address_candidate( self.candidates, SAM_Locators)
def setUp(self): SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"] self.df = pd.DataFrame({ "id": [1], "address": ["89 Orleans Street Boston MA, 02128"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode) self.picked_candidate = self.geocoder._pick_address_candidate( self.candidates, SAM_Locators)
class TestReturnsNoneWhenNoCandidates(unittest.TestCase): def setUp(self): SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"] self.df = pd.DataFrame({ "id": [1], "address": ["This isn't an address"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode) self.picked_candidate = self.geocoder._pick_address_candidate( self.candidates, SAM_Locators) def test_returns_none_when_no_candidates(self): self.assertEqual(self.picked_candidate, None)
class TestAbleToReverseGeocodeToPointAddress(unittest.TestCase): def setUp(self): self.df = pd.DataFrame({"id": [1], "address": ["100 Legends Way"]}) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df = self.geocoder.geocode_df() def test_reverse_geocode_to_point_address(self): self.assertEqual(self.geocode_df["SAM_ID"][0], 340814)
def setUp(self): self.df = pd.DataFrame({ "id": [1, 2], "address": [ "89 Orleans Street Boston MA, 02128", "51 Montebello Road Apt 2 Boston, MA 02130" ] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address)
class TestAbleToCorrectlyPickPointAddressCandidate(unittest.TestCase): def setUp(self): SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"] self.df = pd.DataFrame({ "id": [1], "address": ["89 Orleans Street Boston MA, 02128"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode) self.picked_candidate = self.geocoder._pick_address_candidate( self.candidates, SAM_Locators) def test_picks_highest_score_candidate(self): self.assertEqual(self.picked_candidate["score"], 94.57) def test_picks_expected_candidate(self): self.assertEqual(self.picked_candidate["attributes.Ref_ID"], 105967)
class TestReverseGeocodeFindsPoint(unittest.TestCase): def setUp(self): SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"] self.df = pd.DataFrame({ "id": [1], "address": ["890 Commonwealth Avenue"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode) self.picked_candidate = self.geocoder._pick_address_candidate( self.candidates, SAM_Locators) def test_returns_point_address(self): self.assertEqual(self.picked_candidate["attributes.Ref_ID"], 11864) def test_returns_correct_flag_point_addresses(self): self.assertEqual(self.picked_candidate["flag"], "Able to geocode to a non-SAM address.")
class TestHandlesNotFindingAddressAsExpected(unittest.TestCase): def setUp(self): self.df = pd.DataFrame({ "id": [1], "address": ["This isn't an address."] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df = self.geocoder.geocode_df() def test_reverse_geocode_to_point_address(self): self.assertEqual(self.geocode_df["flag"][0], "Unable to geocode to any address.")
class TestAbleToFindPointAddress(unittest.TestCase): def setUp(self): self.df = pd.DataFrame({ "id": [1], "address": ["1 City Hall Plz, Boston, 02108"] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df = self.geocoder.geocode_df() def test_returns_expected_address(self): print(self.geocode_df["SAM_ID"]) self.assertEqual(self.geocode_df["SAM_ID"][0], 32856)
class TestAbleToHandleNullAddresses(unittest.TestCase): def setUp(self): self.df = pd.DataFrame({ "id": [1, 2], "address": ["89 Orleans Street Boston MA, 02128", None] }) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df_with_Nulls = self.geocoder.geocode_df() def test_handle_null_address(self): self.assertEqual(self.geocode_df_with_Nulls.loc[:, "flag"][1], "No address provided. Unable to geocode.")
class TestAbleToFindAddressCandidates(unittest.TestCase): def setUp(self): self.df = pd.DataFrame({ "id": [1], "address": ["89 Orleans Street Boston MA, 02128"] }) self.address_to_geocode = self.df["address"][0] self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode) self.candidates = self.geocoder._find_address_candidates( self.address_to_geocode) def test_parameters_are_as_expected(self): print(self.candidates) self.assertGreaterEqual(len(self.candidates["candidates"]), 6)
def setUp(self): self.df = pd.DataFrame({"id": [1], "address": ["100 Legends Way"]}) self.address = "address" self.geocoder = CobArcGISGeocoder(self.df, self.address) self.geocode_df = self.geocoder.geocode_df()