summaryrefslogtreecommitdiff
path: root/iss/tests/test_geo.py
blob: 6c25b074f7e199f396ff3cb242086ca45b57e510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest

from ..config import GEOIP_GEOLITE2_CITY_PATH
from ..geo import get_location

geoip_required = pytest.mark.skipif(
    not GEOIP_GEOLITE2_CITY_PATH,
    reason="Path to GeoLite2 city database must be provided",
)


@geoip_required
def test_geo():
    ip = "2.52.2.52"
    location = get_location(ip)
    assert location.latitude == 31.5
    assert location.longitude == 34.75
    assert location.time_zone == "Asia/Jerusalem"


@geoip_required
def test_geo_localhost():
    ip = "127.0.0.1"
    location = get_location(ip)
    assert location.latitude == 34.7641
    assert location.longitude == 32.0669
    assert location.time_zone == "Asia/Jerusalem"