Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from pathlib import Path

scripts_dir = Path(__file__).parent
if str(scripts_dir) not in sys.path:
sys.path.insert(0, str(scripts_dir))
4 changes: 0 additions & 4 deletions Scripts/test_deduplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from io import StringIO
from unittest.mock import patch
import unittest
from unittest.mock import patch
from pathlib import Path

# Add current directory to path to allow importing deduplicate
from Scripts.deduplicate import (
Expand All @@ -14,8 +12,6 @@
is_header,
is_valid_rule,
find_cross_file_duplicates,
deduplicate_file,
Stats,
)


Expand Down
15 changes: 10 additions & 5 deletions Scripts/test_update_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ def test_process_downloaded_file_checksum_fail(self, mock_validate):
mock_aiofiles.files[str(temp_path)] = "some content"

# Using a real Path object instead of MagicMock(spec=Path) because of internal string conversion in mock_aiofiles
with patch.object(Path, "exists", return_value=True), patch.object(
Path, "unlink"
) as mock_unlink:
with (
patch.object(Path, "exists", return_value=True),
patch.object(Path, "unlink") as mock_unlink,
):
result = asyncio.run(
update_lists.process_downloaded_file(
temp_path, "http://url", "final.txt", Path("/tmp/out")
Expand All @@ -163,7 +164,9 @@ def test_process_downloaded_file_checksum_fail(self, mock_validate):
@patch("update_lists.process_downloaded_file")
@patch("tempfile.NamedTemporaryFile")
@patch("asyncio.to_thread")
def test_fetch_list_cleanup_logic(self, mock_to_thread, mock_tempfile, mock_process):
def test_fetch_list_cleanup_logic(
self, mock_to_thread, mock_tempfile, mock_process
):
"""Verify fetch_list handles cleanup in finally block."""

# Mock session response
Expand Down Expand Up @@ -395,7 +398,9 @@ def test_load_sources_existing_config(self):

# Verify list1
self.assertIn("https://example.com/list1.txt", sources)
self.assertEqual(sources["https://example.com/list1.txt"]["filename"], "custom-name.txt")
self.assertEqual(
sources["https://example.com/list1.txt"]["filename"], "custom-name.txt"
)
self.assertTrue(sources["https://example.com/list1.txt"]["skip_checksum"])

# Verify list3 (no filename provided - should use sanitize)
Expand Down
Loading