# Trouve-KA — tests de la politique du frontier # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai from trouveka.frontier import compute_priority, next_recrawl_delay, retry_delay def test_seed_priority_is_max(): assert compute_priority(domain_quebec_score=0, is_seed=True) == 1.0 def test_priority_bounded(): assert 0.0 <= compute_priority(domain_quebec_score=1.0, authority_score=1.0, link_signal=1.0, is_new_domain=True) <= 1.0 assert compute_priority(domain_quebec_score=0.0, spam_signal=1.0, depth=10) == 0.0 def test_quebec_dominates_priority(): high_q = compute_priority(domain_quebec_score=0.9, depth=2) low_q = compute_priority(domain_quebec_score=0.1, depth=2) assert high_q > low_q + 0.2 def test_recrawl_backoff_doubles_when_unchanged(): d = next_recrawl_delay(changed=False, previous_delay_hours=24.0) assert d.total_seconds() == 48 * 3600 def test_recrawl_halves_when_changed(): d = next_recrawl_delay(changed=True, previous_delay_hours=24.0) assert d.total_seconds() == 12 * 3600 def test_recrawl_bounded(): fast = next_recrawl_delay(changed=True, previous_delay_hours=0.5, min_hours=1.0) slow = next_recrawl_delay(changed=False, previous_delay_hours=10_000, max_hours=720) assert fast.total_seconds() == 3600 assert slow.total_seconds() == 720 * 3600 def test_retry_delay_grows_and_caps(): assert retry_delay(0).total_seconds() == 15 * 60 assert retry_delay(1).total_seconds() == 30 * 60 assert retry_delay(10).total_seconds() == 24 * 3600