summaryrefslogtreecommitdiff
path: root/iss/tests/test_utils.py
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2020-09-28 19:24:47 +0300
committerYuval Adam <_@yuv.al>2020-09-28 19:24:47 +0300
commitbeec864ac8a790edeb8df2df68442d0aafdcc77b (patch)
tree7edc0d27469d03e6e6997e91f73ddb7857b7ffda /iss/tests/test_utils.py
parentaa685f4a2b7743ced2ceafc65538eb5457f5ee97 (diff)
Implement normalize_lat_lng()
Diffstat (limited to 'iss/tests/test_utils.py')
-rw-r--r--iss/tests/test_utils.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/iss/tests/test_utils.py b/iss/tests/test_utils.py
index ee4971f..17dadf8 100644
--- a/iss/tests/test_utils.py
+++ b/iss/tests/test_utils.py
@@ -1,4 +1,6 @@
-from ..utils import deg_to_cardinal, seconds_to_minutes
+import pytest
+
+from ..utils import deg_to_cardinal, seconds_to_minutes, normalize_lat_lng
def test_seconds_to_minutes():
@@ -14,6 +16,29 @@ def test_seconds_to_minutes():
assert seconds_to_minutes(secs) == s
+def test_normalize_lat_lng():
+ cases = [
+ ("N12.345", "E67.890", 12.345, 67.890),
+ ("S12.345", "W67.890", -12.345, -67.890),
+ ("S11", "W22", -11, -22),
+ ("N0.987", "W0.123", 0.987, -0.123),
+ ("S88.765", "E177.654", -88.765, 177.654),
+ ]
+ for lat, lng, nlat, nlng in cases:
+ assert normalize_lat_lng(lat, lng) == (nlat, nlng)
+
+
+def test_fail_normalize_lat_lng():
+ failures = [
+ ("12", "E45"),
+ ("B12", "E45"),
+ ("12", "X45"),
+ ]
+ for lat, lng in failures:
+ with pytest.raises(Exception):
+ normalize_lat_lng(lat, lng)
+
+
def test_deg_to_cardinal():
cases = [
(0, "N"),