from backend.app.core.osm_config import (
    DEFAULT_REGIONS,
    STATION_TAG_FILTERS,
    BoundingBox,
    compile_overpass_filters,
)


def test_default_regions_are_valid() -> None:
    assert DEFAULT_REGIONS, "Expected at least one region definition"
    for bbox in DEFAULT_REGIONS:
        assert isinstance(bbox, BoundingBox)
        assert bbox.north > bbox.south
        assert bbox.east > bbox.west
        # Berlin coordinates should fall inside Berlin bounding box for sanity
        if bbox.name == "berlin_metropolitan":
            assert bbox.contains(52.5200, 13.4050)


def test_station_tag_filters_compile_to_overpass_snippet() -> None:
    compiled = compile_overpass_filters(STATION_TAG_FILTERS)
    # Ensure each key is present with its values
    for key, values in STATION_TAG_FILTERS.items():
        assert key in compiled
        for value in values:
            assert value in compiled
    # The snippet should be multi-line to preserve readability
    assert "\n" in compiled
