Skip to content

Commit

Permalink
Fix test that relied on unreliable order
Browse files Browse the repository at this point in the history
  • Loading branch information
pw@slinktopp committed Sep 3, 2009
1 parent 8986f58 commit 993b51d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
1 change: 1 addition & 0 deletions purplevoter/controllers/people.py
Expand Up @@ -133,6 +133,7 @@ def _geocode_address(self, address):
# move

if config.get('mock_geocoder'):
# Intended for use in testing.
address_gen = request.environ['mockgeocoder.results']
else:
google_api_key = config['google_api_key']
Expand Down
27 changes: 6 additions & 21 deletions purplevoter/tests/functional/test_people.py
Expand Up @@ -2,11 +2,6 @@

class TestPeopleController(TestController):

# XXX TODO: factor out a minimal set of geocoder tests,
# get those to use a mock (via test.ini?),
# and test the other stuff by setting lat & lon instead of
# address.

degraw = '669 degraw st., 11217'

mockgeocoder_results = []
Expand Down Expand Up @@ -44,22 +39,12 @@ def test_geocoder_races(self):
response = self.app.get(url(controller='people', action='search', address=self.degraw))
assert isinstance(response.c.races, list)
assert response.c.races, "got empty races list"
assert response.c.races[0].office == u'City Council'
assert response.c.races[1].office == u'Mayor'
assert response.c.races[2].office == u'Comptroller'
assert response.c.races[3].office == u'Public Advocate'


def test_geocoder_election(self):
self.mockgeocoder_results[:] = [(u'669 Degraw St, Brooklyn, NY 11217, USA',
(40.678329400000003, -73.981242499999993))]
response = self.app.get(url(controller='people', action='search', address=self.degraw))
assert isinstance(response.c.races, list)
assert response.c.races, "got empty races list"
assert response.c.races[0].office == u'City Council'
assert response.c.races[1].office == u'Mayor'
assert response.c.races[2].office == u'Comptroller'
assert response.c.races[3].office == u'Public Advocate'
self.assertEqual(len(response.c.races), 4)
offices = sorted(r.office for r in response.c.races)
assert offices[0] == u'City Council'
assert offices[1] == u'Comptroller'
assert offices[2] == u'Mayor'
assert offices[3] == u'Public Advocate'


def test_no_address(self):
Expand Down

0 comments on commit 993b51d

Please sign in to comment.