コード例 #1
0
ファイル: TestExtract.py プロジェクト: joshz/hniextract
    def test_geocode_location_with_no_cache(self, mock_geocode):
        mock_geocode.return_value = mocks.geocoder_multiple()
        l = Location(self._read_data())

        loc = l._geocode(self.city)

        nt.ok_('as_string' in loc and 'location' in  loc and 'options' in loc, 'Wrong keys')
        nt.ok_(len(loc['options']) == 2, 'Coordinate list not available')
コード例 #2
0
ファイル: TestExtract.py プロジェクト: joshz/hniextract
    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")