Exemple #1
0
    def test_returns_geoip_data(self):
        import simple_geoip

        simple_geoip.geoip.API_URI = 'https://geoipify.whoisxmlapi.com/api/v1'
        geoip = simple_geoip.GeoIP(environ.get('API_KEY'))

        self.assertEqual(geoip.lookup('8.8.8.8')['ip'], '8.8.8.8')
Exemple #2
0
    def test_raises_geoip_exception_on_error(self):
        import simple_geoip

        simple_geoip.geoip.API_URI = 'https://api.asdgasggasgdasgdsasgdasdfadfsds.com'
        geoip = simple_geoip.GeoIP('test')

        self.assertRaises(GeoIPException, geoip.lookup, '8.8.8.8')
Exemple #3
0
    def test_raises_service_error_on_error(self):
        import simple_geoip

        simple_geoip.geoip.API_URI = 'https://api.ipify.org/woo'
        geoip = simple_geoip.GeoIP('test')

        self.assertRaises(ServiceError, geoip.lookup, '8.8.8.8')
Exemple #4
0
    def test_raises_connection_error_on_connection_error(self):
        import simple_geoip

        simple_geoip.geoip.API_URI = 'https://api.asdgasggasgdasgdsasgdasdfadfsda.com'
        geoip = simple_geoip.GeoIP('test')

        self.assertRaises(ConnectionError, geoip.lookup, '8.8.8.8')