mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 20:22:03 +03:00
test: cover firehol dir creation in refresh_netsets
This commit is contained in:
parent
44ca9c1786
commit
89a667b666
1 changed files with 18 additions and 0 deletions
|
|
@ -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")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue