This commit is contained in:
Gilles Soulier
2026-01-14 21:54:55 +01:00
parent c91c0f1fc9
commit d0b73b9319
140 changed files with 5822 additions and 161 deletions

0
tests/scraping/__init__.py Executable file → Normal file
View File

0
tests/scraping/__pycache__/__init__.cpython-313.pyc Executable file → Normal file
View File

Binary file not shown.

View File

0
tests/scraping/test_http_fetch.py Executable file → Normal file
View File

30
tests/scraping/test_pipeline.py Executable file → Normal file
View File

@@ -80,3 +80,33 @@ def test_pipeline_respects_disable_flag():
assert product_id is None
with get_session(config) as session:
assert session.query(Product).count() == 0
def test_pipeline_db_error_adds_note(monkeypatch):
"""Une erreur DB ajoute une note et retourne None."""
from sqlalchemy.exc import SQLAlchemyError
class DummyError(SQLAlchemyError):
pass
def raise_session(*args, **kwargs):
raise DummyError("db down")
monkeypatch.setattr("pricewatch.app.scraping.pipeline.get_session", raise_session)
snapshot = ProductSnapshot(
source="amazon",
url="https://example.com/product",
fetched_at=datetime(2026, 1, 14, 13, 0, 0),
title="Produit",
price=10.0,
currency="EUR",
reference="B08PIPE",
debug=DebugInfo(method=FetchMethod.HTTP, status=DebugStatus.SUCCESS),
)
pipeline = ScrapingPipeline(config=FakeAppConfig(db=FakeDbConfig(url="sqlite:///:memory:")))
product_id = pipeline.process_snapshot(snapshot, save_to_db=True)
assert product_id is None
assert any("Persistence DB echouee" in note for note in snapshot.debug.notes)

0
tests/scraping/test_pw_fetch.py Executable file → Normal file
View File