test(bgp): add edge case tests for parse_peeringdb_netixlan

Adds explicit test cases for `parse_peeringdb_netixlan` to cover empty payloads,
missing keys, and items with a false operational status. This increases test
coverage and reliability of the data transformation logic.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-08-26 14:03:54 +00:00
parent 8c99ac78b7
commit 39ae6e4c64

View file

@ -156,6 +156,39 @@ def test_peeringdb_netixlan_lists_only_operational_exchanges(api_fixture):
assert ixps[1].speed_mbps == 200000 assert ixps[1].speed_mbps == 200000
def test_peeringdb_netixlan_of_an_empty_payload():
assert parse_peeringdb_netixlan({}) == []
assert parse_peeringdb_netixlan({"data": None}) == []
assert parse_peeringdb_netixlan({"data": []}) == []
def test_peeringdb_netixlan_ignores_non_operational_entries():
payload = {
"data": [
{"name": "IXP 1", "operational": True},
{"name": "IXP 2", "operational": False},
{"name": "IXP 3"},
]
}
ixps = parse_peeringdb_netixlan(payload)
assert len(ixps) == 1
assert ixps[0].name == "IXP 1"
def test_peeringdb_netixlan_handles_missing_keys():
payload = {
"data": [
{"operational": True}
]
}
ixps = parse_peeringdb_netixlan(payload)
assert len(ixps) == 1
assert ixps[0].name == ""
assert ixps[0].city is None
assert ixps[0].country is None
assert ixps[0].speed_mbps is None
async def test_cached_json_writes_then_reuses_the_cache(tmp_path: Path): async def test_cached_json_writes_then_reuses_the_cache(tmp_path: Path):
calls = [] calls = []