From 7d66064619348185e281bbe0950c8c9502f5b483 Mon Sep 17 00:00:00 2001 From: Igor Starikov Date: Fri, 9 Feb 2024 12:22:05 +0700 Subject: [PATCH] Fix MODE_BATCH (see #16) --- pysyge/pysyge.py | 2 +- tests/test_module.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pysyge/pysyge.py b/pysyge/pysyge.py index e12f806..5821ca5 100644 --- a/pysyge/pysyge.py +++ b/pysyge/pysyge.py @@ -146,7 +146,7 @@ def _search_idx(self, ipn: bytes, min_: int, max_: int) -> int: min_ += 1 - if min_ >= max_: + if min_ > max_: break else: diff --git a/tests/test_module.py b/tests/test_module.py index 385f8d2..91d344e 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -27,6 +27,10 @@ def test_quirks(): result = geodata.get_location('109.207.230.244') assert result['city'] == 'Калининград' + geodata = pysyge.GeoLocator(DATABASE_CITY_FILE, pysyge.MODE_BATCH) + result = geodata.get_location('109.252.119.71', detailed=True) + assert result['info']['city']['name_en'] == 'Moscow' + class TestGeoLocatorBasicCheck: