Skip to content

Commit

Permalink
Fixed some a stale location and whitespace in GeoIP tests.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14416 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jbronn committed Nov 1, 2010
1 parent 315ae1c commit 1ee4274
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions django/contrib/gis/tests/test_geoip.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@


# Note: Requires use of both the GeoIP country and city datasets. # Note: Requires use of both the GeoIP country and city datasets.
# The GEOIP_DATA path should be the only setting set (the directory # The GEOIP_DATA path should be the only setting set (the directory
# should contain links or the actual database files 'GeoIP.dat' and # should contain links or the actual database files 'GeoIP.dat' and
# 'GeoLiteCity.dat'. # 'GeoLiteCity.dat'.
class GeoIPTest(unittest.TestCase): class GeoIPTest(unittest.TestCase):

def test01_init(self): def test01_init(self):
"Testing GeoIP initialization." "Testing GeoIP initialization."
g1 = GeoIP() # Everything inferred from GeoIP path g1 = GeoIP() # Everything inferred from GeoIP path
Expand All @@ -19,7 +19,7 @@ def test01_init(self):
for g in (g1, g2, g3): for g in (g1, g2, g3):
self.assertEqual(True, bool(g._country)) self.assertEqual(True, bool(g._country))
self.assertEqual(True, bool(g._city)) self.assertEqual(True, bool(g._city))

# Only passing in the location of one database. # Only passing in the location of one database.
city = os.path.join(path, 'GeoLiteCity.dat') city = os.path.join(path, 'GeoLiteCity.dat')
cntry = os.path.join(path, 'GeoIP.dat') cntry = os.path.join(path, 'GeoIP.dat')
Expand Down Expand Up @@ -52,10 +52,10 @@ def test02_bad_query(self):
def test03_country(self): def test03_country(self):
"Testing GeoIP country querying methods." "Testing GeoIP country querying methods."
g = GeoIP(city='<foo>') g = GeoIP(city='<foo>')

fqdn = 'www.google.com' fqdn = 'www.google.com'
addr = '12.215.42.19' addr = '12.215.42.19'

for query in (fqdn, addr): for query in (fqdn, addr):
for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name): for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name):
self.assertEqual('US', func(query)) self.assertEqual('US', func(query))
Expand All @@ -67,7 +67,7 @@ def test03_country(self):
def test04_city(self): def test04_city(self):
"Testing GeoIP city querying methods." "Testing GeoIP city querying methods."
g = GeoIP(country='<foo>') g = GeoIP(country='<foo>')

addr = '130.80.29.3' addr = '130.80.29.3'
fqdn = 'chron.com' fqdn = 'chron.com'
for query in (fqdn, addr): for query in (fqdn, addr):
Expand All @@ -78,7 +78,7 @@ def test04_city(self):
self.assertEqual('United States', func(query)) self.assertEqual('United States', func(query))
self.assertEqual({'country_code' : 'US', 'country_name' : 'United States'}, self.assertEqual({'country_code' : 'US', 'country_name' : 'United States'},
g.country(query)) g.country(query))

# City information dictionary. # City information dictionary.
d = g.city(query) d = g.city(query)
self.assertEqual('USA', d['country_code3']) self.assertEqual('USA', d['country_code3'])
Expand All @@ -87,7 +87,7 @@ def test04_city(self):
self.assertEqual(713, d['area_code']) self.assertEqual(713, d['area_code'])
geom = g.geos(query) geom = g.geos(query)
self.failIf(not isinstance(geom, GEOSGeometry)) self.failIf(not isinstance(geom, GEOSGeometry))
lon, lat = (-95.4152, 29.7755) lon, lat = (-95.3670, 29.7523)
lat_lon = g.lat_lon(query) lat_lon = g.lat_lon(query)
lat_lon = (lat_lon[1], lat_lon[0]) lat_lon = (lat_lon[1], lat_lon[0])
for tup in (geom.tuple, g.coords(query), g.lon_lat(query), lat_lon): for tup in (geom.tuple, g.coords(query), g.lon_lat(query), lat_lon):
Expand Down

0 comments on commit 1ee4274

Please sign in to comment.