'GeoIP initialization.'

def test01_init(self):

    g1 = GeoIP2()
    path = settings.GEOIP_PATH
    g2 = GeoIP2(path, 0)
    g3 = GeoIP2.open(path, 0)
    for g in (g1, g2, g3):
        self.assertTrue(g._country)
        self.assertTrue(g._city)
    city = os.path.join(path, 'GeoLite2-City.mmdb')
    cntry = os.path.join(path, 'GeoLite2-Country.mmdb')
    g4 = GeoIP2(city, country='')
    self.assertIsNone(g4._country)
    g5 = GeoIP2(cntry, city='')
    self.assertIsNone(g5._city)
    bad_params = (23, 'foo', 15.23)
    for bad in bad_params:
        with self.assertRaises(GeoIP2Exception):
            GeoIP2(cache=bad)
        if isinstance(bad, str):
            e = GeoIP2Exception
        else:
            e = TypeError
        with self.assertRaises(e):
            GeoIP2(bad, 0)
