Skip to content

Commit 3132948

Browse files
committed
add batch test case for sync handler
1 parent 88b35cd commit 3132948

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/handler_test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ def test_get_details(n):
7979
assert len(domains["domains"]) == 5
8080

8181

82+
@pytest.mark.parametrize("n", range(5))
83+
def test_get_batch_details(n):
84+
token = os.environ.get("IPINFO_TOKEN", "")
85+
handler = Handler(token)
86+
ips = ["1.1.1.1", "8.8.8.8", "9.9.9.9"]
87+
details = handler.getBatchDetails(ips)
88+
89+
for ip in ips:
90+
assert ip in details
91+
d = details[ip]
92+
assert d["ip"] == ip
93+
assert d["country"] == "US"
94+
assert d["country_name"] == "United States"
95+
if token:
96+
assert "asn" in d
97+
assert "company" in d
98+
assert "privacy" in d
99+
assert "abuse" in d
100+
assert "domains" in d
101+
102+
82103
def test_builtin_ip_types():
83104
handler = Handler()
84105
fake_details = {"country": "US", "ip": "127.0.0.1", "loc": "12.34,56.78"}

0 commit comments

Comments
 (0)