# ============================================================================== # Author: Simon-Pierre Boucher # File: tests/test_linkinbio.py # Desc: Tests du connecteur générique link-in-bio sur fixture réelle figée — # extraction des comptes avec signal fort (0.95) # ============================================================================== from pathlib import Path from creaka.connectors.linkinbio import extract_accounts, is_supported, parse_links FIXTURE = (Path(__file__).parent / "fixtures" / "linktree_sample.html").read_text() def test_is_supported(): assert is_supported("https://linktr.ee/nom") assert is_supported("https://beacons.ai/nom") assert not is_supported("https://exemple.com/nom") assert not is_supported(None) def test_parse_links_next_data_et_ancres(): links = parse_links(FIXTURE) assert "https://www.youtube.com/@CreatriceExemple" in links assert "https://www.instagram.com/creatrice.exemple" in links # ancre de repli def test_extract_accounts_signal_fort(): accounts = extract_accounts(FIXTURE) by_platform = {a.platform: a for a in accounts} assert by_platform["youtube"].handle == "creatriceexemple" assert by_platform["tiktok"].handle == "creatrice.exemple" assert by_platform["twitch"].handle == "creatriceexemple" assert by_platform["patreon"].handle == "creatriceexemple" assert by_platform["x"].handle == "creatrice_ex" assert all(a.confidence == 0.95 for a in accounts) # signal link_in_bio assert all(a.signal == "link_in_bio" for a in accounts) # la boutique (site marchand) et le reel (page générique) ne sont PAS des comptes assert "site-web" not in by_platform or "boutique" not in \ by_platform.get("site-web").handle