feat: add test framework, unit tests, and GitLab CI pipeline #1
@@ -156,7 +156,8 @@ class TestLookupGeo:
|
||||
lp._geo_reader = None
|
||||
|
||||
@patch("app.log_parser.settings")
|
||||
def test_ip_maps_to_country(self, mock_settings):
|
||||
@patch("app.log_parser.os.path.exists", return_value=True)
|
||||
def test_ip_maps_to_country(self, mock_exists, mock_settings):
|
||||
"""Verify a known IP resolves to a country code via the GeoLite2 reader."""
|
||||
self._reset_geo_reader()
|
||||
mock_settings.GEOLITE2_DB_PATH = "/tmp/fake-geo.mmdb"
|
||||
@@ -179,7 +180,8 @@ class TestLookupGeo:
|
||||
assert result["longitude"] == -74.006
|
||||
|
||||
@patch("app.log_parser.settings")
|
||||
def test_ip_without_coordinates_uses_centroid_fallback(self, mock_settings):
|
||||
@patch("app.log_parser.os.path.exists", return_value=True)
|
||||
def test_ip_without_coordinates_uses_centroid_fallback(self, mock_exists, mock_settings):
|
||||
"""When the free GeoLite2 DB lacks coordinates, centroid fallback kicks in."""
|
||||
self._reset_geo_reader()
|
||||
mock_settings.GEOLITE2_DB_PATH = "/tmp/fake-geo.mmdb"
|
||||
|
||||
Reference in New Issue
Block a user