test: cover firehol dir creation in refresh_netsets

This commit is contained in:
Andrew Pimenov 2026-08-19 16:42:00 +03:00
parent 44ca9c1786
commit 89a667b666

View file

@ -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): 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_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") httpx_mock.add_response(url="http://example.com/firehol_level2.netset", text="198.51.100.0/24\n")