- Add SPA support for Playwright with wait_for_network_idle and extra_wait_ms - Add BaseStore.get_spa_config() and requires_playwright() methods - Implement AliExpress SPA config with JSON price extraction patterns - Fix Amazon price parsing to prioritize whole+fraction combination - Fix AliExpress regex patterns (remove double backslashes) - Add CLI tests: detect, doctor, fetch, parse, run commands - Add API tests: auth, logs, products, scraping_logs, webhooks Tests: 417 passed, 85% coverage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""Tests pour la commande CLI detect."""
|
|
|
|
import pytest
|
|
from typer.testing import CliRunner
|
|
|
|
from pricewatch.app.cli.main import app
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
class TestDetectCommand:
|
|
"""Tests pour la commande detect."""
|
|
|
|
def test_detect_amazon_url(self):
|
|
"""Detect doit identifier une URL Amazon."""
|
|
result = runner.invoke(app, ["detect", "https://www.amazon.fr/dp/B08N5WRWNW"])
|
|
assert result.exit_code == 0
|
|
assert "amazon" in result.stdout.lower()
|
|
assert "B08N5WRWNW" in result.stdout
|
|
|
|
def test_detect_cdiscount_url(self):
|
|
"""Detect doit identifier une URL Cdiscount."""
|
|
result = runner.invoke(
|
|
app,
|
|
[
|
|
"detect",
|
|
"https://www.cdiscount.com/informatique/f-10709-tuf608umrv004.html",
|
|
],
|
|
)
|
|
assert result.exit_code == 0
|
|
assert "cdiscount" in result.stdout.lower()
|
|
|
|
def test_detect_unknown_url(self):
|
|
"""Detect doit echouer pour une URL inconnue."""
|
|
result = runner.invoke(app, ["detect", "https://www.unknown-store.com/product"])
|
|
assert result.exit_code == 1
|
|
assert "aucun store" in result.stdout.lower()
|
|
|
|
def test_detect_invalid_url(self):
|
|
"""Detect doit echouer pour une URL invalide."""
|
|
result = runner.invoke(app, ["detect", "not-a-valid-url"])
|
|
assert result.exit_code == 1
|