'Testing GeoIP initialization.'

def test01_init(self):

    g1 = GeoIP()
    path = settings.GEOIP_PATH
    g2 = GeoIP(path, 0)
    g3 = GeoIP.open(path, 0)
    for g in (g1, g2, g3):
        self.assertEqual(True, bool(g._country))
        self.assertEqual(True, bool(g._city))
    city = os.path.join(path, u'GeoLiteCity.dat')
    cntry = os.path.join(path, u'GeoIP.dat')
    g4 = GeoIP(city, country=u'')
    self.assertEqual(None, g4._country)
    g5 = GeoIP(cntry, city=u'')
    self.assertEqual(None, g5._city)
    bad_params = (23, u'foo', 15.23)
    for bad in bad_params:
        self.assertRaises(GeoIPException, GeoIP, cache=bad)
        if isinstance(bad, six.string_types):
            e = GeoIPException
        else:
            e = TypeError
        self.assertRaises(e, GeoIP, bad, 0)
