Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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.")