jobhunt-platform/packages/matching/tests/conftest.py

184 lines
No EOL
6.8 KiB
Python

"""Shared fixtures for matching tests.
Provides agency-repost fixture triples and a legit-different-jobs-same-agency
negative case.
"""
from __future__ import annotations
import pytest
# ---------------------------------------------------------------------------
# Agency-repost fixture triples.
# Three realistic scenarios where agencies repost the same job.
# Each triple is a list of 3 posting dicts that should all cluster together.
# ---------------------------------------------------------------------------
# Triple 1: Same role, two agencies + direct employer posting.
# All three have the same title and nearly identical description, but
# different employer names (the two agencies vs the actual company).
TRIPLE_1_AGENCY_REPOST = [
{
"id": "t1-a",
"employer": "TechCorp AB",
"title": "Senior Python Developer",
"description": (
"We are looking for a Senior Python Developer to join our backend team. "
"You will work with Fast API, PostgreSQL, and Docker in a cloud-native "
"environment. 5+ years of Python experience required. "
"Experience with AWS and Kubernetes is a plus."
),
},
{
"id": "t1-b",
"employer": "Nordic IT Consulting AB",
"title": "Senior Python Developer",
"description": (
"We are looking for a Senior Python Developer to join our backend team. "
"You will work with Fast API, PostgreSQL, and Docker in a cloud-native "
"environment. 5+ years of Python experience required. "
"Experience with AWS and Kubernetes is a plus."
),
},
{
"id": "t1-c",
"employer": "Acme Recruitment Group",
"title": "Senior Python Developer",
"description": (
"We are looking for a Senior Python Developer to join our backend team. "
"You will work with Fast API, PostgreSQL, and Docker in a cloud-native "
"environment. 5+ years of Python experience required. "
"Experience with AWS and Kubernetes is a plus."
),
},
]
# Triple 2: Same role reposted by same agency with minor wording variations.
TRIPLE_2_SAME_AGENCY_REPOST = [
{
"id": "t2-a",
"employer": "Stockholm Tech Staffing AB",
"title": "Fullstack Engineer",
"description": (
"Fullstack Engineer wanted for a fintech startup in Stockholm. "
"Tech stack: React, TypeScript, Node.js, PostgreSQL. "
"You will build customer-facing features and internal tools. "
"Must have experience with CI/CD pipelines."
),
},
{
"id": "t2-b",
"employer": "Stockholm Tech Staffing AB",
"title": "Fullstack Engineer",
"description": (
"Fullstack Engineer wanted for a fintech startup in Stockholm. "
"Tech stack: React, TypeScript, Node.js, PostgreSQL. "
"You will build customer-facing features and internal tools. "
"Must have experience with CI/CD pipelines."
),
},
{
"id": "t2-c",
"employer": "Stockholm Tech Staffing",
"title": "Fullstack Engineer",
"description": (
"Fullstack Engineer wanted for a fintech startup in Stockholm. "
"Tech stack: React, TypeScript, Node.js, PostgreSQL. "
"You will build customer-facing features and internal tools. "
"Must have experience with CI/CD pipelines."
),
},
]
# Triple 3: Same role, slightly different title but same description body.
# Different employers (agencies), high title + desc similarity.
TRIPLE_3_CROSS_AGENCY = [
{
"id": "t3-a",
"employer": "Data Recruiting Solutions",
"title": "Data Engineer",
"description": (
"We seek a Data Engineer to build and maintain ETL pipelines using "
"Python, Airflow, dbt, and Snowflake. You will design data models, "
"optimize queries, and ensure data quality. Experience with "
"distributed systems and Spark is required."
),
},
{
"id": "t3-b",
"employer": "Cloud Talent Partners",
"title": "Data Engineer",
"description": (
"We seek a Data Engineer to build and maintain ETL pipelines using "
"Python, Airflow, dbt, and Snowflake. You will design data models, "
"optimize queries, and ensure data quality. Experience with "
"distributed systems and Spark is required."
),
},
{
"id": "t3-c",
"employer": "Analytics Staffing Ltd",
"title": "Data Engineer",
"description": (
"We seek a Data Engineer to build and maintain ETL pipelines using "
"Python, Airflow, dbt, and Snowflake. You will design data models, "
"optimize queries, and ensure data quality. Experience with "
"distributed systems and Spark is required."
),
},
]
# ---------------------------------------------------------------------------
# NEGATIVE case: legit different jobs at same agency -- must NOT cluster.
# Same agency employer but different titles and different descriptions.
# ---------------------------------------------------------------------------
NEGATIVE_DIFFERENT_JOBS_SAME_AGENCY = [
{
"id": "neg-a",
"employer": "Nordic IT Consulting AB",
"title": "Frontend Developer",
"description": (
"We are looking for a Frontend Developer with expertise in React "
"and TypeScript. You will build responsive web applications and "
"work closely with our design team. Experience with CSS-in-JS and "
"accessibility standards is required."
),
},
{
"id": "neg-b",
"employer": "Nordic IT Consulting AB",
"title": "DevOps Engineer",
"description": (
"We need a DevOps Engineer to manage our Kubernetes clusters and "
"CI/CD pipelines. You will work with Terraform, ArgoCD, and "
"Prometheus monitoring. Strong Linux and networking background "
"is required. AWS certification is a plus."
),
},
]
@pytest.fixture
def triple1():
"""Agency repost triple 1: same role, two agencies + employer."""
return [dict(p) for p in TRIPLE_1_AGENCY_REPOST]
@pytest.fixture
def triple2():
"""Agency repost triple 2: same agency reposts same job."""
return [dict(p) for p in TRIPLE_2_SAME_AGENCY_REPOST]
@pytest.fixture
def triple3():
"""Agency repost triple 3: cross-agency same role same description."""
return [dict(p) for p in TRIPLE_3_CROSS_AGENCY]
@pytest.fixture
def negative_same_agency():
"""Negative case: different jobs at same agency, must NOT cluster."""
return [dict(p) for p in NEGATIVE_DIFFERENT_JOBS_SAME_AGENCY]