summaryrefslogtreecommitdiff
path: root/iss/tests/test_geo.py
diff options
context:
space:
mode:
Diffstat (limited to 'iss/tests/test_geo.py')
-rw-r--r--iss/tests/test_geo.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/iss/tests/test_geo.py b/iss/tests/test_geo.py
new file mode 100644
index 0000000..c63c2d6
--- /dev/null
+++ b/iss/tests/test_geo.py
@@ -0,0 +1,26 @@
+import pytest
+
+from ..config import GEOIP_CITY_PATH
+from ..geo import get_location
+
+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"
+ 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"