From 89a667b6664d00291189a6ce9b9c85e747f188b2 Mon Sep 17 00:00:00 2001 From: Andrew Pimenov Date: Wed, 19 Aug 2026 16:42:00 +0300 Subject: [PATCH] test: cover firehol dir creation in refresh_netsets --- tests/test_reputation.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_reputation.py b/tests/test_reputation.py index 3760918..708ff15 100644 --- a/tests/test_reputation.py +++ b/tests/test_reputation.py @@ -297,6 +297,24 @@ def providers(): ] ) +async def test_refresh_netsets_setup_dir(httpx_mock, tmp_path, providers): + httpx_mock.add_response(url="http://example.com/firehol_level1.netset", text="192.0.2.0/24\n") + httpx_mock.add_response(url="http://example.com/firehol_level2.netset", text="198.51.100.0/24\n") + + import pathlib + + original_mkdir = pathlib.Path.mkdir + + def mocked_mkdir(self, *args, **kwargs): + return original_mkdir(self, *args, **kwargs) + + with patch("pathlib.Path.mkdir", side_effect=mocked_mkdir, autospec=True) as mock_mkdir: + async with httpx.AsyncClient() as client: + await refresh_netsets(client, providers, tmp_path) + + mock_mkdir.assert_any_call(tmp_path / "firehol", parents=True, exist_ok=True) + + async def test_refresh_netsets_downloads_new_lists_and_caches_them(httpx_mock, tmp_path, providers): httpx_mock.add_response(url="http://example.com/firehol_level1.netset", text="192.0.2.0/24\n") httpx_mock.add_response(url="http://example.com/firehol_level2.netset", text="198.51.100.0/24\n")