mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
test(ingest): mock boto3 client in tests; fix FeedParser._parse_date to raise ValueError on invalid input
This commit is contained in:
@@ -359,9 +359,14 @@ class FeedParser:
|
||||
|
||||
return parser.parse(date_string)
|
||||
except (ImportError, OSError):
|
||||
# If dateutil isn't available, fall through to raising ValueError
|
||||
pass
|
||||
except Exception as e:
|
||||
# If dateutil fails to parse, raise ValueError to signal invalid input
|
||||
raise ValueError(f"Invalid date format: {date_string}") from e
|
||||
|
||||
return None
|
||||
# No known formats matched and dateutil is unavailable; raise ValueError
|
||||
raise ValueError(f"Invalid date format: {date_string}")
|
||||
|
||||
def validate_feed(self, feed_data: FeedData) -> bool:
|
||||
"""
|
||||
|
||||
@@ -7,6 +7,7 @@ from unittest.mock import MagicMock
|
||||
# and we must populate the attributes that the code tries to import/patch.
|
||||
|
||||
module_names = [
|
||||
"boto3",
|
||||
"google",
|
||||
"google.cloud",
|
||||
"google.cloud.storage",
|
||||
@@ -23,6 +24,7 @@ for name in module_names:
|
||||
# Explicitly add the classes that will be patched/used
|
||||
sys.modules["google.cloud.storage"].Client = MagicMock()
|
||||
sys.modules["azure.storage.blob"].BlobServiceClient = MagicMock()
|
||||
sys.modules["boto3"].client = MagicMock()
|
||||
|
||||
from pathlib import Path # noqa: E402
|
||||
from unittest.mock import patch # noqa: E402
|
||||
|
||||
Reference in New Issue
Block a user