35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
import unittest
|
|
import tempfile
|
|
from map_manager.engine import MapEngine
|
|
|
|
|
|
class TestEngineEdgeCases(unittest.TestCase):
|
|
def test_antimeridian_bbox_returns_image(self):
|
|
# BBox crossing the antimeridian: e.g. west 179, east -179 (covers small area)
|
|
bbox = (179.0, -1.0, -179.0, 1.0)
|
|
# Use offline mode so test does not require network
|
|
engine = MapEngine(service_name='osm', cache_dir=None, enable_online=False)
|
|
|
|
# Request image with explicit small max_size to force zoom selection
|
|
img = engine.get_image_for_area(bbox, zoom=None, max_size=800)
|
|
# Should return a PIL image (placeholder-based) even if tiles are not downloaded
|
|
self.assertIsNotNone(img)
|
|
# Basic sanity: image should have width and height > 0
|
|
self.assertGreater(img.size[0], 0)
|
|
self.assertGreater(img.size[1], 0)
|
|
|
|
def test_max_zoom_not_exceed_service_limit(self):
|
|
# Large bbox (global) with very large max_size; engine should pick a zoom
|
|
bbox = (-179.0, -85.0, 179.0, 85.0)
|
|
engine = MapEngine(service_name='osm', cache_dir=None, enable_online=False)
|
|
chosen = engine._choose_zoom_for_bbox(bbox, max_size_pixels=20000)
|
|
self.assertIsNotNone(chosen)
|
|
# chosen zoom must be within service bounds
|
|
max_zoom = engine.tile_manager.map_service.max_zoom
|
|
self.assertGreaterEqual(chosen, 0)
|
|
self.assertLessEqual(chosen, max_zoom)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|