Read the Se jobbet link off a Jobindex vis-job page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 13:26:20 +02:00
1 parent a19c528e3f
commit 54b56ac370
5 files changed
+300 -1

No files matched your search

+36
View File
@@ -100,3 +100,39 @@ def test_an_answer_without_a_channel_raises() -> None:
def test_saved_params_keep_the_query_and_a_real_area() -> None:
assert jobindex.clean_params({"q": "x", "area": "3"}) == {"q": "x", "area": 3}
assert jobindex.clean_params({"q": "x", "area": 0}) == {"q": "x"}
# ------------------------------------------------- the link out of a vis-job page
PAGES = ROOT / "tests" / "fixtures" / "jobindex"
@pytest.mark.parametrize("name, link", [
("vis-job-employer.html",
"https://careers.kfforsikring.dk/jobs/8456088-loesningsarkitekt-til-koebstaedernes-forsikring"
"?promotion=2220670-jobindex"),
("vis-job-thehub.html",
"https://thehub.io/jobs/6ab5030dfd5518f38b6960b2"
"?utm_source=jobindex&utm_medium=jobboard&utm_content=dk"),
("vis-job-jobannonce.html",
"https://www.jobindex.dk/jobannonce/r14009457/"
"lead-software-engineer-research-tech-delivery-ai-digital-innovation"),
])
def test_posting_link_is_the_se_jobbet_button_of_a_saved_page(name: str, link: str) -> None:
assert jobindex.posting_link((PAGES / name).read_text(encoding="utf-8")) == link
def test_posting_link_skips_other_ads_and_is_empty_without_a_button() -> None:
other = '<a class="btn" href="/c?t=h1&amp;ctx=w&amp;ctt=r&amp;u=2">Se jobbet</a>'
assert jobindex.posting_link(other) == ""
assert jobindex.posting_link("<p>Ingen knap</p>") == ""
assert jobindex.posting_link("") == ""
mine = '<A HREF="https://a.example/x?a=1&amp;b=2" rel="noopener">\n Se jobbet </A>'
assert jobindex.posting_link(other + mine) == "https://a.example/x?a=1&b=2"
def test_posting_link_is_absolute_and_never_a_script() -> None:
assert jobindex.posting_link('<a href="/jobannonce/r1/x">Se jobbet</a>') \
== "https://www.jobindex.dk/jobannonce/r1/x"
assert jobindex.posting_link('<a href="javascript:alert(1)">Se jobbet</a>') == ""
assert jobindex.posting_link('<a class="x">Se jobbet</a>') == ""