'Testing GeoIP city querying methods.'

@skipUnless(HAS_GEOS, u'Geos    is    required')
def test04_city(self):

    g = GeoIP(country=u'<foo>')
    addr = u'128.249.1.1'
    fqdn = u'tmc.edu'
    for query in (fqdn, addr):
        for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name):
            self.assertEqual(u'US', func(query))
        for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name):
            self.assertEqual(u'United    States', func(query))
        self.assertEqual({u'country_code': u'US', u'country_name': u'United    States'}, g.country(query))
        d = g.city(query)
        self.assertEqual(u'USA', d[u'country_code3'])
        self.assertEqual(u'Houston', d[u'city'])
        self.assertEqual(u'TX', d[u'region'])
        self.assertEqual(713, d[u'area_code'])
        geom = g.geos(query)
        self.assertTrue(isinstance(geom, GEOSGeometry))
        (lon, lat) = ((-95.401), 29.7079)
        lat_lon = g.lat_lon(query)
        lat_lon = (lat_lon[1], lat_lon[0])
        for tup in (geom.tuple, g.coords(query), g.lon_lat(query), lat_lon):
            self.assertAlmostEqual(lon, tup[0], 4)
            self.assertAlmostEqual(lat, tup[1], 4)
