blob: aa3f37d6713a1ba8886bcdb8acda4d5e45c0c0b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import pytest
import geoip2.database
from ..config import GEOIP_CITY_PATH
geoip_required = pytest.mark.skipif(
not GEOIP_CITY_PATH, reason="Path to GeoLite2 city database must be provided"
)
@geoip_required
def test_geo():
ip = "2.52.2.52"
with geoip2.database.Reader(GEOIP_CITY_PATH) as reader:
res = reader.city(ip)
location = res.location
assert location.latitude == 31.5
assert location.longitude == 34.75
assert location.time_zone == "Asia/Jerusalem"
|