示例#1
0
    def test_geocode_location_with_cache(self, mock_geocode):
        mock_geocode.return_value = mocks.geocoder_multiple()

        with patch('hniextract.cache.Cache') as MockCache:
            instance = MockCache.return_value
            instance.put.return_value = mocks.cache_put()
            instance.get.return_value = mocks.cache_get()
            with instance:
                l = Location(self._read_data(), instance)
                loc = l._geocode(self.city)

            nt.ok_(len(loc['location']) == 3, "Location doesn't have necesary components")
            nt.ok_(len(loc['options']) == 2, "Length of coordinate list not correct")
示例#2
0
    def test_geocode_all_cache(self, mock_geocode):
        mock_geocode.return_value = mocks.geocoder_multiple()

        with patch('hniextract.cache.Cache') as MockCache:
            instance = MockCache.return_value
            instance.put.return_value = mocks.cache_put()
            instance.get.return_value = mocks.cache_get()
            with instance:
                l = Location(self._read_data(), instance)
                locs = l._geocode_all(['Dallas', 'Paris', 'Las Vegas'])

            nt.ok_(len(locs) == 3, "Not enough locations found")
            nt.ok_(len(locs[1]['location']) == 3, "Location doesn't have necessary componenets")
            nt.ok_(len(locs[2]['options']) == 2, "Not enough guessed locations")