| import unittest | |
| from src.location import extract_coordinates_from_text, parse_lat_lon | |
| class LocationTests(unittest.TestCase): | |
| def test_parse_plain_lat_lon(self): | |
| self.assertEqual(parse_lat_lon("21.002, 70.245"), (21.002, 70.245)) | |
| def test_extract_google_maps_at_coordinates(self): | |
| text = "https://www.google.com/maps/@21.12345,70.54321,16z" | |
| self.assertEqual(extract_coordinates_from_text(text), (21.12345, 70.54321)) | |
| def test_extract_google_maps_query_coordinates(self): | |
| text = "https://maps.google.com/?q=21.12345,70.54321" | |
| self.assertEqual(extract_coordinates_from_text(text), (21.12345, 70.54321)) | |
| def test_invalid_coordinates_return_none(self): | |
| self.assertIsNone(parse_lat_lon("not a coordinate")) | |
| if __name__ == "__main__": | |
| unittest.main() | |