fixed tests

This commit is contained in:
2026-05-15 20:41:05 +02:00
parent 96ce516ecf
commit 77df5d5d65
50 changed files with 1482 additions and 5089 deletions

View File

@@ -138,7 +138,7 @@ class TestListHistory:
new=AsyncMock(return_value=f2b_db_path),
):
result = await history_service.list_history("fake_socket")
assert result.pagination.total == 4
assert result.total == 4
assert len(result.items) == 4
async def test_time_range_filter_excludes_old_bans(
@@ -153,7 +153,7 @@ class TestListHistory:
result = await history_service.list_history(
"fake_socket", range_="24h"
)
assert result.pagination.total == 2
assert result.total == 2
async def test_jail_filter(self, f2b_db_path: str) -> None:
"""Jail filter restricts results to bans from that jail."""
@@ -162,7 +162,7 @@ class TestListHistory:
new=AsyncMock(return_value=f2b_db_path),
):
result = await history_service.list_history("fake_socket", jail="nginx")
assert result.pagination.total == 1
assert result.total == 1
assert result.items[0].jail == "nginx"
async def test_ip_prefix_filter(self, f2b_db_path: str) -> None:
@@ -174,7 +174,7 @@ class TestListHistory:
result = await history_service.list_history(
"fake_socket", ip_filter="1.2.3"
)
assert result.pagination.total == 2
assert result.total == 2
for item in result.items:
assert item.ip.startswith("1.2.3")
@@ -188,7 +188,7 @@ class TestListHistory:
"fake_socket", jail="sshd", ip_filter="1.2.3.4"
)
# 2 sshd bans for 1.2.3.4
assert result.pagination.total == 2
assert result.total == 2
async def test_origin_filter_selfblock(self, f2b_db_path: str) -> None:
"""Origin filter should include only selfblock entries."""
@@ -200,7 +200,7 @@ class TestListHistory:
"fake_socket", origin="selfblock"
)
assert result.pagination.total == 4
assert result.total == 4
assert all(item.jail != "blocklist-import" for item in result.items)
async def test_unknown_ip_returns_empty(self, f2b_db_path: str) -> None:
@@ -212,7 +212,7 @@ class TestListHistory:
result = await history_service.list_history(
"fake_socket", ip_filter="99.99.99.99"
)
assert result.pagination.total == 0
assert result.total == 0
assert result.items == []
async def test_failures_extracted_from_data(
@@ -226,7 +226,7 @@ class TestListHistory:
result = await history_service.list_history(
"fake_socket", ip_filter="5.6.7.8"
)
assert result.pagination.total == 1
assert result.total == 1
assert result.items[0].failures == 3
async def test_matches_extracted_from_data(
@@ -287,7 +287,7 @@ class TestListHistory:
result = await history_service.list_history(
"fake_socket", ip_filter="9.0.0.1"
)
assert result.pagination.total == 1
assert result.total == 1
item = result.items[0]
assert item.failures == 0
assert item.matches == []
@@ -301,10 +301,10 @@ class TestListHistory:
result = await history_service.list_history(
"fake_socket", page=1, page_size=2
)
assert result.pagination.total == 4
assert result.total == 4
assert len(result.items) == 2
assert result.pagination.page == 1
assert result.pagination.page_size == 2
assert result.page == 1
assert result.page_size == 2
async def test_source_archive_reads_from_archive(self, f2b_db_path: str, tmp_path: Path) -> None:
"""Using source='archive' reads from the BanGUI archive table."""
@@ -328,7 +328,7 @@ class TestListHistory:
db=db,
)
assert result.pagination.total == 1
assert result.total == 1
assert result.items[0].ip == "10.0.0.1"
@@ -363,8 +363,8 @@ class TestGetIpDetail:
assert result is not None
assert result.ip == "1.2.3.4"
assert result.pagination.total_bans == 2
assert result.pagination.total_failures == 10 # 5 + 5
assert result.total_bans == 2
assert result.total_failures == 10 # 5 + 5
async def test_timeline_ordered_newest_first(
self, f2b_db_path: str