summaryrefslogtreecommitdiff
path: root/iss/tests
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2020-09-28 21:40:01 +0300
committerYuval Adam <_@yuv.al>2020-09-28 21:40:20 +0300
commitc81aeba984b08957614f7167cdbdea8780e76a11 (patch)
tree8b08a714a19fc48f466af6286943b4eddc3423a2 /iss/tests
parentf4844cd8c546d1bc6f689ffe95274596c14cc6c6 (diff)
Add geoip tests
Diffstat (limited to 'iss/tests')
-rw-r--r--iss/tests/test_geoip.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/iss/tests/test_geoip.py b/iss/tests/test_geoip.py
new file mode 100644
index 0000000..aa3f37d
--- /dev/null
+++ b/iss/tests/test_geoip.py
@@ -0,0 +1,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"