Skip to content

Commit

Permalink
Simplify test location data, don’t wrap raw fields in components dict
Browse files Browse the repository at this point in the history
  • Loading branch information
jlev committed Jul 11, 2017
1 parent 1affbef commit e7b7c57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion call_server/political_data/geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ def _find_in_raw(self, field):
return self.raw['address'].get(field)
elif self.service == LOCAL_USDATA_SERVICE:
return self.raw.get(field)
else:
# try simple extraction from raw
return self.raw.get(field)
except KeyError:
try:
# try simple extraction from raw
# fallback to raw
return self.raw.get(field)
except KeyError, ValueError:
raise ValueError('unable to parse raw fields from geocoder service '+self.service)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ca_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUp(self, **kwargs):

# well, really montreal
self.mock_location = Location('North Pole', (45.500577, -73.567427),
{'components':{'province':'QC','postal_code':'H0H 0H0'}})
{'province':'QC','postal_code':'H0H 0H0'})

def test_cache(self):
self.assertIsNotNone(self.mock_cache)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_us_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def setUp(self, **kwargs):

# avoid geocoding round-trip
self.mock_location = Location('Boston, MA', (42.355662,-71.065483),
{'components':{'state':'MA','zipcode':'02111'}})
{'state':'MA','zipcode':'02111'})

# this zipcode pretty evenly split between KY-2 & TN-7
self.mock_location_multiple_states = Location('Fort Campbell, KY', (36.647207, -87.451635),
{'components':{'state':'KY','zipcode':'42223'}})
{'state':'KY','zipcode':'42223'})

# this zipcode pretty evenly split between WI-2 & WI-3
self.mock_location_multiple_districts = Location('Hazel Green, WI', (42.532498, -90.436727),
{'components':{'state':'WI','zipcode':'53811'}})
{'state':'WI','zipcode':'53811'})

def test_cache(self):
self.assertIsNotNone(self.mock_cache)
Expand Down

0 comments on commit e7b7c57

Please sign in to comment.