diff --git a/overpass/api.py b/overpass/api.py index f3f8651a9ac..0536c75dca8 100644 --- a/overpass/api.py +++ b/overpass/api.py @@ -148,9 +148,13 @@ def _api_status() -> dict: available_re = re.compile(r'\d(?= slots? available)') available_slots = int( - available_re.search(lines[3]).group() - if available_re.search(lines[3]) - else 0 + next( + ( + available_re.search(line).group() + for line in lines + if available_re.search(line) + ), 0 + ) ) waiting_re = re.compile(r'(?<=Slot available after: )[\d\-TZ:]{20}') diff --git a/tests/overpass_status/no_slots_waiting_six_lines.txt b/tests/overpass_status/no_slots_waiting_six_lines.txt new file mode 100644 index 00000000000..20d2659b0ac --- /dev/null +++ b/tests/overpass_status/no_slots_waiting_six_lines.txt @@ -0,0 +1,6 @@ +Connected as: 0123456789 +Current time: 2022-06-15T22:13:27Z +Announced endpoint: lz4.overpass-api.de/api/ +Rate limit: 2 +2 slots available now. +Currently running queries (pid, space limit, time limit, start time): diff --git a/tests/test_api.py b/tests/test_api.py index dc3657b32e2..d3603a16067 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -89,6 +89,12 @@ def test_geojson_live(): @pytest.mark.parametrize( "response,slots_available,slots_running,slots_waiting", [ + ( + "tests/overpass_status/no_slots_waiting_six_lines.txt", + 2, + (), + () + ), ( "tests/overpass_status/no_slots_waiting.txt", 2,