'GeoIP city querying methods.'

@mock.patch('socket.gethostbyname')
def test04_city(self, gethostbyname):

    gethostbyname.return_value = '128.249.1.1'
    g = GeoIP2(country='<foo>')
    for query in (self.fqdn, self.addr):
        self.assertEqual('US', g.country_code(query), ('Failed    for    func    country_code    and    query    %s' % query))
        self.assertEqual('United    States', g.country_name(query), ('Failed    for    func    country_name    and    query    %s' % query))
        self.assertEqual({'country_code': 'US', 'country_name': 'United    States'}, g.country(query))
        d = g.city(query)
        self.assertEqual('US', d['country_code'])
        self.assertEqual('Houston', d['city'])
        self.assertEqual('TX', d['region'])
        self.assertEqual('America/Chicago', d['time_zone'])
        geom = g.geos(query)
        self.assertIsInstance(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)
